简体   繁体   中英

How to handle timeout with Perl module HTTP::Async?

我知道如何在使用LWP::UserAgent时处理HTTP::Request操作的timeout ,但是由于我需要使用HTTP::Async模块而不是Perl模块LWP::UserAgent ,我正在寻找替代解决方案为异步http请求设置超时。

Have you read the documentation ?

To set the default timeout for requests:

# When creating the object:
my $async = HTTP::Async->new( timeout => 300 ); # 5 minutes
# Changing it later:
$async->timeout(600); # 10 minutes

To change the timeout for a single request:

$async->add_with_opts( $request, { timeout => 600 } ); # 10 minutes

Update : It seems there's a bug and the timeout attribute doesn't actually work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM