Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set grequests timeout

How would I accomplish the following:

rs = (self.exporter.grequester(url) for url in url_chunk)
res_items = grequests.map(rs, timeout=10s) # this is the item that times out
like image 933
David542 Avatar asked Jul 25 '15 01:07

David542


People also ask

How to add timeout to Python Requests?

Timeouts in Python requests You can tell requests library to stop waiting for a response after a given amount of time by passing a number to the timeout parameter. If the requests library does not receive response in x seconds, it will raise a Timeout error.

What is default timeout for Python Requests?

The default timeout is None , which means it'll wait (hang) until the connection is closed.


1 Answers

Try this:

reqs = grequests.map(grequests.get(link, headers=header,  timeout=1) for link in links)

source

like image 189
Natan Avatar answered Oct 21 '22 03:10

Natan