我正在使用 grequests 模块发出异步请求。在测试以下代码时,显示基于 TIMEOUT 值的异常:
>>> grequests.map((grequests.get('http://httpbin.org/delay/1',timeout=0.6),),exception_handler=exception_handler)
failed: http://httpbin.org/delay/1
[<Response [200]>]
>>> grequests.map((grequests.get('http://httpbin.org/delay/1', timeout=0.001),),exception_handler=exception_handler)
failed: http://httpbin.org/delay/1
[None]
那么timeout 的值如何影响 exception_handling 最后一部分的执行呢?
>>> def exception_handler(r,e):
print('failed: ',r.url,'\n')
#changing the url just for doing sth
r.url = 'http://httpbin.org/status/200'
res = r.send().response
return res