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

exception and thread safety #548

Open
6 tasks done
casperdcl opened this issue May 4, 2018 · 7 comments
Open
6 tasks done

exception and thread safety #548

casperdcl opened this issue May 4, 2018 · 7 comments
Assignees
Labels
help wanted 🙏 We need you (discussion or implementation) p0-bug-critical ☢ Exception rasing p2-bug-warning ⚠ Visual output bad p3-enhancement 🔥 Much new such feature to-fix ⌛ In progress
Milestone

Comments

@casperdcl
Copy link
Member

casperdcl commented May 4, 2018

@chengs
Copy link
Contributor

chengs commented Sep 21, 2018

Also related to #611

casperdcl added a commit that referenced this issue Oct 15, 2018
- fix `str.isnumeric` #605
- fix `WeakSet` `KeyError` #548, #553, #596 -> #607
- stop `tqdm_notebook` description truncation #582 -> #599
- include `unit_scale` for `rate` #608
- add `auto` -> nowarning `autonotebook`
- add better postfix numeric formatting #621
- minor refactoring #609 -> #616
- update documentation
- add unit tests
- fix py26 CI
casperdcl added a commit that referenced this issue Oct 15, 2018
- fix `str.isnumeric` #605
- fix `WeakSet` `KeyError` #548, #553, #596 -> #607
- stop `tqdm_notebook` description truncation #582 -> #599
- include `unit_scale` for `rate` #608
- add `auto` -> nowarning `autonotebook`
- add better postfix numeric formatting #621
- minor refactoring #609 -> #616
- update documentation
- add unit tests
- fix py26 CI
@fabianp
Copy link

fabianp commented Oct 29, 2018

Are there any workarounds around this? I tried wrapping the code under a try/except block and closing pbar in case of an exception but it didn't seem to solve the issue

@acbart
Copy link

acbart commented Dec 21, 2018

Yeah, interesting behavior. It seems like if an exception gets triggered at any point, inner progressbars get spawned on new lines instead of staying on the previous line.

@casperdcl
Copy link
Member Author

@fabianp you mean this doesn't work for you?

try:
    with tqdm(...) as t:
        for i in t:
            ...
except KeyboardInterrupt:
    t.close()
    raise
t.close()

@aldanor
Copy link
Contributor

aldanor commented Jan 24, 2020

Any further thoughts on this?

I've copied and pasted this hundreds of times now... this gets even worse if you actually need direct access to progressbar object, then you have to use contextmanagers etc. Feels like something of the sort should really be hard-baked into tqdm itself?

def tqdm_iter(iterable):
    pbar = tqdm.tqdm(iterable)
    try:
        yield from pbar
    finally:
        pbar.close()

@casperdcl casperdcl modified the milestones: >5, v5.0.0 Jan 25, 2020
@casperdcl casperdcl added the to-fix ⌛ In progress label Jan 25, 2020
casperdcl added a commit that referenced this issue Mar 29, 2020
- fixes (partially) #548
@casperdcl casperdcl mentioned this issue Mar 29, 2020
2 tasks
casperdcl added a commit that referenced this issue Mar 29, 2020
- fixes (partially) #548
casperdcl added a commit that referenced this issue Mar 29, 2020
- fixes (partially) #548
This was referenced Apr 30, 2020
@xoxoxo13102020
Copy link

from tqdm import tqdm as tqdm

worked for me

@casperdcl
Copy link
Member Author

casperdcl commented Nov 11, 2020

It should be exception safe (tqdm>=4.45.0 or even better tqdm>=4.50.0). You don't need to wrap in try/except/finally.

It's just built-in thread safety which sometimes needs to be manually dealt with (maybe should be different issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted 🙏 We need you (discussion or implementation) p0-bug-critical ☢ Exception rasing p2-bug-warning ⚠ Visual output bad p3-enhancement 🔥 Much new such feature to-fix ⌛ In progress
Projects
None yet
Development

No branches or pull requests

6 participants