Skip to content Skip to sidebar Skip to footer

Asyncio Aiohttp Progress Bar With Tqdm

I'm attempting to integrate a tqdm progress bar to monitor POST requests generated with aiohttp in Python 3.5. I have a working progress bar but can't seem to gather results using

Solution 1:

await f returns a single response. Why would you pass an already completed Future to asyncio.gather(f) is unclear.

Try:

responses = []
for f in tqdm.tqdm(asyncio.as_completed(tasks), total=len(tasks)):
    responses.append(await f)

Python 3.6 implements PEP 530 -- Asynchronous Comprehensions:

responses = [await f
             for f in tqdm.tqdm(asyncio.as_completed(tasks), total=len(tasks))]

It works inside async def functions now.

Post a Comment for "Asyncio Aiohttp Progress Bar With Tqdm"