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

fix current thread join runtime error #641

Closed
wants to merge 1 commit into from
Closed

Conversation

chengs
Copy link
Contributor

@chengs chengs commented Nov 13, 2018

This PR fixes #613

Explain:
When exit, a TMonitor thread wants to join itself, but if it cannot do that if it is the current thread, which will raise an error as in File "/Users/guchen/anaconda3/lib/python3.6/threading.py"

if self is current_thread():
            raise RuntimeError("cannot join current thread")

I just add one line to check whether it is the current thread. See #613 for more discussion. In fact, it rarely happens. For instance, in a case that the main thread is killed by accident (eg, by errors) and only the TMonitor thread remains.

Code to reproduce the error

from time import sleep
from tqdm.auto import tqdm

for i in tqdm(range(10)):
    if i == 3:
        sleep(20)
        raise Exception("Wrong!")
    else:
        sleep(1)

@codecov-io
Copy link

Codecov Report

Merging #641 into master will decrease coverage by 0.13%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #641      +/-   ##
==========================================
- Coverage   98.78%   98.65%   -0.14%     
==========================================
  Files          10       10              
  Lines         743      744       +1     
  Branches      132      133       +1     
==========================================
  Hits          734      734              
  Misses          5        5              
- Partials        4        5       +1

@iainsmith
Copy link

Hit this today when streaming downloads with requests.

@jlmeunier
Copy link

Thanks for this fix (worked for me, on this particular issue)

@chengs
Copy link
Contributor Author

chengs commented Jan 4, 2019

ping...

@casperdcl casperdcl closed this in 6081329 Jan 6, 2019
@EKami
Copy link

EKami commented Jun 7, 2019

I don't get it, why this PR wasn't merged? Is this bug fixed? I just ran into it today but I'm not sure I was on the latest version of tqdm. I'll relaunch the process with the last version this time.

@Limmen
Copy link

Limmen commented Apr 3, 2020

This bug still occurs on master and latest release, had to downgrade to 4.21.0 to avoid it. What's the status on this?

@casperdcl
Copy link
Sponsor Member

This PR was merged in 6081329, fixing #613. if you're still getting an error which you believe is #613, please post the error output in #613...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-bug-warning ⚠ Visual output bad to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeError: cannot join current thread
7 participants