Skip to content

Instantly share code, notes, and snippets.

@yko
Created January 1, 2011 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yko/762000 to your computer and use it in GitHub Desktop.
Save yko/762000 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Mojo::Client;
my $client = Mojo::Client->new;
my $child = Mojo::Client->new;
for my $q (0 .. 10) {
$client->get(
'http://google.com/?q=' . $q => sub {
my ($cli, $tx) = @_;
warn "Parent got " . $tx->req->url . "\n";
# How to make this subrequest non-blocking?
$child->get(
'http://finance.ua/?q=' . $tx->req->url => sub {
my ($cli, $tx) = @_;
warn "Child got " . $tx->req->url . "\n";
}
)->start;
}
);
}
$client->start;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment