Created
August 17, 2011 06:52
-
-
Save anonymous/1150975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $ua = Mojo::UserAgent->new; | |
my $t = Mojo::IOLoop::Trigger->new; | |
for my $step (1..5) { | |
for my $thread (1..2) { | |
say "==> $step - $thread"; | |
$ua->get( | |
'www.twitter.com', | |
sub { | |
say "<== $step - $thread"; | |
} | |
); | |
} | |
} | |
$ua->start; | |
Is it possible to automatically wait at the end of each step till all sent requests have finished? | |
So, instead of: | |
==> 1 - 1 | |
==> 1 - 2 | |
==> 2 - 1 | |
==> 2 - 2 | |
==> 3 - 1 | |
==> 3 - 2 | |
==> 4 - 1 | |
==> 4 - 2 | |
==> 5 - 1 | |
==> 5 - 2 | |
Non-blocking requests in progress at test_ua.pl line 23 | |
it should display: | |
==> 1 - 1 | |
==> 1 - 2 | |
<== 1 - 1 | |
<== 1 - 2 | |
==> 2 - 1 | |
==> 2 - 2 | |
<== 2 - 1 | |
<== 2 - 2 | |
......... | |
Looked through Mojo::IOLoop::Trigger but didn't get how I can use it for my purpose. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment