Closed
Description
Right now _DummyThread
claims to not allow join
:
Lines 1453 to 1458 in fb0d9b9
But, it can be easily changed with python -OO
mode, which strips assert
statements.
The easiest way to check this is:
# ex.py
import threading, _thread
def f(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 thread
But, python -OO ex.py
results in:
done
This looks like an important behavior change. I propose to use explicit AssertionError
/ RuntimeError
instead.
I have a PR ready.