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.
This commit is contained in:
Tim Peters 2002-02-16 07:26:27 +00:00
parent e73ad2a21f
commit 20882dd174
2 changed files with 13 additions and 5 deletions

View file

@ -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):