Skip to content

Instantly share code, notes, and snippets.

@joshlk
Created May 31, 2019 13:58
Show Gist options
  • Save joshlk/11a3a3f127becbf81647a85f15835612 to your computer and use it in GitHub Desktop.
Save joshlk/11a3a3f127becbf81647a85f15835612 to your computer and use it in GitHub Desktop.
Progress bar for Python Trio tasks using tqdm
import trio
import tqdm
class TrioProgress(trio.abc.Instrument):
def __init__(self, total, notebook_mode=False, **kwargs):
if notebook_mode:
from tqdm import tqdm_notebook as tqdm
else:
from tqdm import tqdm
self.tqdm = tqdm(total=total, **kwargs)
def task_exited(self, task):
self.tqdm.update(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment