mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
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:
parent
e73ad2a21f
commit
20882dd174
2 changed files with 13 additions and 5 deletions
|
@ -17,9 +17,13 @@ def task():
|
|||
x = random.randrange(1, 3)
|
||||
critical_section.acquire()
|
||||
N -= 1
|
||||
if N == 0:
|
||||
done.release()
|
||||
# Must release critical_section before releasing done, else the main
|
||||
# thread can exit and set critical_section to None as part of global
|
||||
# teardown; then critical_section.release() raises AttributeError.
|
||||
finished = N == 0
|
||||
critical_section.release()
|
||||
if finished:
|
||||
done.release()
|
||||
|
||||
# Tricky: When regrtest imports this module, the thread running regrtest
|
||||
# grabs the import lock and won't let go of it until this module returns.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue