A neat little trick with tqdm that allows you to track the progress of asynchronous coroutines in Python:
# aws is any set of awaitables - coroutines in this case
for future in tqdm.tqdm(asyncio.as_completed(aws)):
result = await future
# Handle results as they are completed
asyncio.as_completed schedules the execution of the coroutine objects and returns a iterable of
Future objects, each representing the earliest result from the remaining set of coroutines.
tqdm.tqdm takes any iterable and generates a progress meter from it, we can simply wrap the result of
await the result of the next earliest
Future object in each iteration, effectively providing a progress meter representing the execution progress of the set of coroutines.
asyncio.as_completed takes a set of any awaitable (i.e. any object that can be used in an
await expression), so this would also work with
Task objects in addition to coroutines.