简体   繁体   English

如何使用Perl模块HTTP :: Async处理超时?

[英]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. 更新 :似乎有一个错误timeout属性实际上不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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