diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-02-16 07:26:27 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-02-16 07:26:27 (GMT) |
commit | 20882dd1742310c8cf6858354ecb150810adb95c (patch) | |
tree | a5f09339b4f43cbdf9464e9586dcdac65bf19a0d /Lib/test/test_thread.py | |
parent | e73ad2a21f997f0d18195207972fb31a09b0b1c1 (diff) | |
download | cpython-20882dd1742310c8cf6858354ecb150810adb95c.zip cpython-20882dd1742310c8cf6858354ecb150810adb95c.tar.gz cpython-20882dd1742310c8cf6858354ecb150810adb95c.tar.bz2 |
SF bug #516372: test_thread: unhandled exc. in thread
Fix exit races in test_thread.py and test_threaded_import.py.
I suspect the bug is provokable only under Linux (where child threads
seem to get lots of cycles before they get killed after the main thread
exits), or on multi-processor machines running other OSes.
Bugfix candidate.
Diffstat (limited to 'Lib/test/test_thread.py')
-rw-r--r-- | Lib/test/test_thread.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index 02da94e..a45fb2f 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -97,10 +97,14 @@ def task2(ident): if verbose: print 'task', ident, 'leaving barrier', i mutex.acquire() - running = running - 1 - if running == 0: - done.release() + running -= 1 + # Must release mutex before releasing done, else the main thread can + # exit and set mutex to None as part of global teardown; then + # mutex.release() raises AttributeError. + finished = running == 0 mutex.release() + if finished: + done.release() print '\n*** Barrier Test ***' if done.acquire(0): |