Apr-29-2021, 06:17 AM
I need to pull a random proxy from a list in an async method but the code exits the method as soon as it hits the line of code:
Thanks.
proxy = random.choice(proxy_list)Here's the full method and the next line (the "print" line) never executes.
async def download_site(session, url): proxy_list = [ (754, '38.39.205.220:80'), (681, '38.39.204.100:80'), (682, '38.39.204.101:80'), (678, '38.39.204.94:80') ] proxy = random.choice(proxy_list) print(proxy[1]) async with session.get(url, proxy="http://" + proxy[1]) as response: print("Read {0} from {1}".format(response.content_length, url))Can someone please share a work-around or a fix for this?
Thanks.