Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Last active April 18, 2024 21:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nikhilkumarsingh/be174036a47d50ca4a7a9c48885f534c to your computer and use it in GitHub Desktop.
Save nikhilkumarsingh/be174036a47d50ca4a7a9c48885f534c to your computer and use it in GitHub Desktop.
Displaying Progress Bar for Concurrent Tasks
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@casperdcl
Copy link

if you use the auto version:

-from tqdm.notebook import tqdm
+from tqdm.auto import tqdm

you can simplify this:

-tqdm(asyncio.as_completed(tasks), total=N)
+tqdm.as_completed(tasks)

You also may as well use a list comprehension in do2() as in do1():

-    for t in tqdm(asyncio.as_completed(tasks), total=N):
-        await t
+    [await t for t in tqdm.as_completed(tasks)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment