notebook: Progress bar updating problem following kernel interrupt

Using a progress bar to monitor computation progress in the notebook (e.g. tqdm) runs into a visual updating glitch when run following the kernel being interrupted (either by keyboard or a break statement). Any progress bar run after the interruption results in output like the following:

Only a restart of the kernel restores behavior.

Running notebook 4.4.1 on macOS 10.12.3 and Safari (Python 3.6).

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 17
  • Comments: 17 (1 by maintainers)

Most upvoted comments

None of the above works for me. I find that running to following sorts this issue after error (It just clears all the instances of progress bars in the background):

from tqdm import tqdm

# blah blah your code errored

tqdm._instances.clear()

(If you would like to updoot - I’ve posted this solution on stack)

It works if you go on of the ways:

pbar = tqdm(range(10))
try:
    for i in pbar:
        sleep(1)
        if i==5:
            raise NotImplementedError()
finally:
    pbar.close()

or

with tqdm(range(10)) as pbar:
    for i in pbar:
        sleep(1)
        if i==5:
            raise NotImplementedError()

Going through this issue as well. If anyone has a solution please let me know.

@takluyver @fonnesbeck Same issue here as well! The only solution I stumbled over so far is to restart the kernel. Also, if you interrupt multiple times, it accumulates lines between every update. For example, two interrupts would accumulate two lines. Look at the following: screen shot 2017-03-06 at 3 52 46 pm

The bug affects me as well: if I interrupt in the middle of the tqdm bar, I must restart the kernel to avoid this issue. This is tedious because it is very common to interrupt long processes (you hit ctrl-enter, and check for bugs or improvements while the job is running, if any found, you interrupt, fix and re-run).

For those of you using tqdm, use tqdm_notebook instead.

See: https://github.com/tqdm/tqdm/issues/375#issuecomment-328466265

Any ideas on this one? It continues to be an issue in current master.