Parallel requests in Mojolicious application
问题 I have perl application which, for example, parallel searching in google: use Mojo::UserAgent; use Mojo::IOLoop; my $ua = Mojo::UserAgent->new(); my $delay = Mojo::IOLoop->delay(sub { say 'DONE1 (should be before render)'; }); foreach my $i ( 1 .. 10 ) { $delay->begin(); $ua->get("http://www.google.ru/search?q=$i" => sub { say $i; $delay->end(); }); } $delay->wait() unless $delay->ioloop->is_running(); say 'DONE2 (should be before render)'; say 'Found! (render)'; And it's works fine: 6 1 7 10