asyncio aiohttp progress bar with tqdm

后端 未结 1 749
温柔的废话
温柔的废话 2020-12-13 19:59

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 c

相关标签:
1条回答
  • 2020-12-13 20:23

    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.

    0 讨论(0)
提交回复
热议问题