Advertisement
Guest User

Untitled

a guest
Jan 19th, 2012
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.28 KB | None | 0 0
  1. sub timed {
  2.   my $cb = pop;
  3.   my ($self, $url) = @_;
  4.   my $is_done;
  5.  
  6.   my $done = sub {
  7.     return if $is_done;
  8.     $is_done = 1;
  9.     $cb->(@_);
  10.   };
  11.  
  12.   Mojo::IOLoop->timer($self->timeout, sub { $done->(Mojo::Transaction::HTTP->new) });
  13.   $self->ua->get($url, $done);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement