Skip to content

Commit

Permalink
fix delay for notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hansen authored and casperdcl committed Apr 5, 2021
1 parent a162d02 commit a22aebc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tqdm/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,10 @@ def __init__(self, *args, **kwargs):
total = self.total * unit_scale if self.total else self.total
self.container = self.status_printer(self.fp, total, self.desc, self.ncols)
self.container.pbar = self
if display_here:
self.displayed = False
if display_here and self.delay <= 0:
display(self.container)
self.displayed = True
self.disp = self.display
self.colour = colour

Expand All @@ -256,6 +258,9 @@ def __iter__(self):
# since this could be a shared bar which the user will `reset()`

def update(self, n=1):
if not self.displayed and self.delay > 0:
display(self.container)
self.displayed = True
try:
return super(tqdm_notebook, self).update(n=n)
# NB: except ... [ as ...] breaks IPython async KeyboardInterrupt
Expand Down

0 comments on commit a22aebc

Please sign in to comment.