tqdm/tqdm

Incorrect progress updates when using `thread_map`

joelostblom opened this issue · 1 comments

I'm running a thread_map with five inner loops, each with it's own progress bar. However, instead of updating 20% per completed bar, the outer loop updates 20% for the first three together (should be 60%) and then another 80% (should be 40%) when the last two completes:

recording-2024-04-13_10.47.03.mp4

(the reason for sleep in the beginning is to make sure the outer bar is on top, I think due to this issue #1496). process_map behaves similarly but I don't see the inner bars.

from tqdm.auto import tqdm

def inner_pbar(step):
    sleep(0.2)
    with tqdm(total=100) as pbar:
        for i in range(20):
            pbar.update(5)
            sleep(0.2)

thread_map(inner_pbar, range(5), max_workers=3, desc='Outer loop')
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
import tqdm, sys
print(tqdm.__version__, sys.version, sys.platform)
# 4.66.2 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0] linux