Monday, 19 July 2021

convert async object into a list

I'm trying to get a list of proxies from proxybroker:

import asyncio
from proxybroker import Broker

async def show(proxies):
    while True:
        proxy = await proxies.get()
        if proxy is None: break
        print('Found proxy: %s' % proxy)

proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(
    broker.find(types=['HTTP', 'HTTPS'], limit=10),
    show(proxies))

loop = asyncio.get_event_loop()
result_now = loop.run_until_complete(tasks)

However, I'm not sure how to convert the final result into a normal list. Any help? Thanks!



from convert async object into a list

No comments:

Post a Comment