I got sick of waiting around for urequests to give up on bad connections so I tried timing it out by running it as a thread. Instead of
Code: Select all
_request("GET", url)
Code: Select all
def _timeout(method, url):
response=0; import _thread; _thread.start_new_thread(_request, (method, url))
for i in range(5): # 5s timeout for dns+srvr
if response: return response
time.sleep(1)
_timeout("GET", url)
Code: Select all
def _timeout(method, url):
response=0; asyncio.create_task(_request(method, url)); await asyncio.sleep(0)
for i in range(5): # 5s timeout for dns+srvr
if response: return response
time.sleep(1)
_timeout("GET", url)
>>AttributeError: generator object has no attribute text