> On Oct 23, 2020, at 10:42 AM, Dmitry L. <dim0...@gmail.com> wrote: > >> my $p = $ua->get_p('http://www.google.com'); >> > https://metacpan.org/pod/Mojo::UserAgent#get_p returns a Mojo::Promise object > >> Mojo::Promise->timer(0.01)->then( sub { print "canceling\n"; $p->completed() >> } ); >> > https://metacpan.org/pod/Mojo::Promise doesn't have `completed` method > your are calling > > You have to build Mojo::Transaction via $ua->build_tx and do ->completed on it
Follow-up to this … it’s still not canceling. ===== use v5.26; use Mojo::UserAgent; $| = 1; my $ua = Mojo::UserAgent->new(); my $tx = $ua->build_tx( GET => 'http://google.com' ); $tx->on( connection => sub { $tx->completed(); say "canceled" } ); $ua->start_p($tx)->then( sub { say "finished" } ); Mojo::IOLoop->timer(2, sub { Mojo::IOLoop->stop() }); Mojo::IOLoop->start(); ===== It prints “canceled”, but strace shows that it continues with the request after then. Is there something else I need to do? Sebastian: Do you recall off-hand which tests set a response error from the client logic? I’ve looked over the ones that seem like they might be related, but I’ve not found it. Thank you both! cheers, -Felipe -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/598A1F26-9A63-45E1-80A5-7EA543D69EE6%40felipegasper.com.