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
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.
The default timeout is None , which means it'll wait (hang) until the connection is closed.
Try this:
reqs = grequests.map(grequests.get(link, headers=header, timeout=1) for link in links)
source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With