use 5.016;use Mojo::UserAgent;my $ua = Mojo::UserAgent->new;say "starting " . scalar localtime();my $tx = Mojo::Transaction::HTTP->new;$tx->req->method('GET');$tx->req->url->parse('http://www.google.com/');$ua->start($tx => \&mojo_callback);$tx = Mojo::Transaction::HTTP->new;$tx->req->method('GET');$tx->req->url->parse('http://www.google.com/');$ua->start($tx => \&mojo_callback);sub mojo_callback{my ($ua, $tx) = @_;say $tx->res->code . " " . scalar localtime() ;}Mojo::IOLoop->start unless Mojo::IOLoop->is_running;say "after is_running " . scalar localtime();
use strict; use warnings; use Mojo::UserAgent; use Mojo::IOLoop; my $ua = Mojo::UserAgent->new; my $delay = Mojo::IOLoop->delay(sub { my $delay = shift; exit(0); }); foreach my $url ('http://www.google.com/', 'http://www.google.com/') { my $end = $delay->begin(0); $ua->get($url => sub { say $tx->res->code . ' ' . scalar(localtime()); $end->(); }); } Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.