Skip to content

Instantly share code, notes, and snippets.

@skaurus
Created October 16, 2011 14:52
Show Gist options
  • Save skaurus/1290973 to your computer and use it in GitHub Desktop.
Save skaurus/1290973 to your computer and use it in GitHub Desktop.
Mojo/EV bug part 2
#!/usr/local/bin/perl
use 5.012;
BEGIN { $ENV{MOJO_POLL} = 0; };
use Mojolicious::Lite;
use AnyEvent::HTTP;
post '/hitme' => sub {
my $self = shift;
eval {
my $cv = AnyEvent->condvar;
my $t = AE::timer 0, 0, sub {
http_request(
GET => 'http://google.com',
timeout => 10,
#body => $data,
persistent => 0,
sub {
my ($body, $hdr) = @_;
#%headers = map { lc $_ => $hdr->{ $_ } } keys %{ $hdr };
$cv->send();
}
);
};
$cv->recv();
};
if ($@) {
warn "miss: $@";
}
$self->render(text => 'OK');
warn 'rendered...';
};
# Start the Mojolicious command system
warn 'Starting';
app->start();
@skaurus
Copy link
Author

skaurus commented Oct 22, 2011

Ok, it's possibly because I basically nesting one EV event loop inside another.
But this worked for few months! Without Mojo updating.

There are kind of bugs that you think after fixing it "it should never be working in the first place..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment