Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Right now_DummyThread claims to not allowjoin:
Lines 1453 to 1458 infb0d9b9
| defis_alive(self): | |
| assertnotself._is_stoppedandself._started.is_set() | |
| returnTrue | |
| defjoin(self,timeout=None): | |
| assertFalse,"cannot join a dummy thread" |
But, it can be easily changed withpython -OO mode, which stripsassert statements.
The easiest way to check this is:
# ex.pyimportthreading,_threaddeff(mutex):threading.current_thread()mutex.release()mutex=threading.Lock()mutex.acquire()tid=_thread.start_new_thread(f, (mutex,))mutex.acquire()threading._active[tid].join()print('done')
python ex.py results in:
Traceback (most recent call last): File "/Users/sobolev/Desktop/cpython/ex.py", line 12, in <module> threading._active[tid].join() File "/Users/sobolev/Desktop/cpython/Lib/threading.py", line 1458, in join assert False, "cannot join a dummy thread"AssertionError: cannot join a dummy threadBut,python -OO ex.py results in:
doneThis looks like an important behavior change. I propose to use explicitAssertionError /RuntimeError instead.
I have a PR ready.