Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random duplicated line on multithreaded progress bard update #1305

Closed
1 of 4 tasks
joaompinto opened this issue Mar 6, 2022 · 6 comments · May be fixed by #1502
Closed
1 of 4 tasks

Random duplicated line on multithreaded progress bard update #1305

joaompinto opened this issue Mar 6, 2022 · 6 comments · May be fixed by #1502

Comments

@joaompinto
Copy link

  • [ X] I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • [X ] 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.63.0 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] linux

from tqdm import tqdm
import time
from concurrent.futures import ThreadPoolExecutor, as_completed

layers = [{"size" : 1000}, {"size" : 1000}]

The following code, randomly produces a 3rd line duplicating the content of the previous line:

def download_layer(layer, position):
    total = layer['size']
    with tqdm(total=total, position=position, ascii=True) as pbar:
        for n in range(int(total / 50)):
            time.sleep(0.01)
            pbar.update(50)


with ThreadPoolExecutor(max_workers=len(layers)) as ex:
    futures = []
    for i, layer in enumerate(layers):
        futures.append(ex.submit(download_layer, layer, i))
    for future in as_completed(futures):
        result = future.result()
```

It was tested running python from Windows + WSL2 and the VSCode Terminal.
@joaompinto
Copy link
Author

wsl2_bug

@jithu7432
Copy link

image

@jithu7432
Copy link

jithu7432 commented Jun 2, 2022

Works fine on fish, but on bash I am having problems.
NB: also tested with bash --noprofile --norc

@mjpieters
Copy link

This is almost certainly the same issue as #1496.

Could you try my PR fix (#1502) for that issue? You can install it in your local virtualenv by using

pip install git+https://github.com/tqdm/tqdm.git@refs/pull/1502/merge

@joaompinto
Copy link
Author

Works fine now.
Thanks

@mjpieters
Copy link

Glad it works! Note that the PR has not yet been merged however; if the PR is accepted and merged, issues like these would be closed automatically (provided I add them to the 'fixes' list, which I do when I get confirmations like this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants