Skip to content

Instantly share code, notes, and snippets.

@kgoess
Created July 12, 2017 22:50
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 kgoess/49fc4e8ad6eab84687f7d2d8a218e4d0 to your computer and use it in GitHub Desktop.
Save kgoess/49fc4e8ad6eab84687f7d2d8a218e4d0 to your computer and use it in GitHub Desktop.
allow caller to provide the ioloop
--- /usr/share/perl5/vendor_perl/Mojo/UserAgent.pm 2017-03-13 17:13:52.000000000 +0000
+++ /home/kgoess/mylib/lib/perl5/Mojo/UserAgent.pm 2017-07-12 22:46:18.000000000 +0000
@@ -43,21 +43,21 @@
sub start {
my ($self, $tx, $cb) = @_;
# Fork-safety
$self->_cleanup->server->restart unless ($self->{pid} //= $$) eq $$;
# Non-blocking
if ($cb) {
warn "-- Non-blocking request (@{[_url($tx)]})\n" if DEBUG;
- return $self->_start(Mojo::IOLoop->singleton, $tx, $cb);
+ return $self->_start($self->ioloop, $tx, $cb);
}
# Blocking
warn "-- Blocking request (@{[_url($tx)]})\n" if DEBUG;
$self->_start($self->ioloop, $tx => sub { shift->ioloop->stop; $tx = shift });
$self->ioloop->start;
return $tx;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment