Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
"be consistent"
 
PerlMonks  

Re^3: Timeout for connect in Anyevent::HTTP. Help, please.

by Tanktalus (Canon)
on Oct 11, 2013 at 15:26 UTC ( #1057909=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Timeout for connect in Anyevent::HTTP. Help, please.
in thread Timeout for connect in Anyevent::HTTP. Help, please.

Without testing anything:

my $w; my $cv = http_request GET => $url, ..., sub { $w = undef; callback(... +) }; # kill the watcher when we're done $w = AE::timer $timeout, 0, sub { $cv = undef }; # kill the http requ +est after $timeout seconds
However, that may not work depending on what else you're doing - if you're waiting on $cv->recv, you may want to use $cv->send() if $cv inside the timer callback to trigger that.

Basically, start the request, then start the timer, then wait, and when the http request returns, clear the $cv variable and/or clear $w to terminate the timer. There are a few things to pay attention to here, to clear cv's and watchers at the appropriate time, but it should otherwise be straight forward.


Comment on Re^3: Timeout for connect in Anyevent::HTTP. Help, please.
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057909]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-04-20 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls