[Python-checkins] CVS: python/dist/src/Lib/test test_thread.py,1.9,1.9.24.1 test_threaded_import.py,1.4,1.4.14.1
Michael Hudson
mwh@users.sourceforge.net
Fri, 22 Feb 2002 05:29:34 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv16961
Modified Files:
Tag: release22-maint
test_thread.py test_threaded_import.py
Log Message:
backport tim_one's checkin of
revision 1.10 of test_thread.py
revision 1.5 of test_threaded_import.py
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.
Index: test_thread.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_thread.py,v
retrieving revision 1.9
retrieving revision 1.9.24.1
diff -C2 -d -r1.9 -r1.9.24.1
*** test_thread.py 17 Jan 2001 21:51:36 -0000 1.9
--- test_thread.py 22 Feb 2002 13:29:32 -0000 1.9.24.1
***************
*** 98,105 ****
print 'task', ident, 'leaving barrier', i
mutex.acquire()
! running = running - 1
! if running == 0:
! done.release()
mutex.release()
print '\n*** Barrier Test ***'
--- 98,109 ----
print 'task', ident, 'leaving barrier', i
mutex.acquire()
! 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 ***'
Index: test_threaded_import.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_threaded_import.py,v
retrieving revision 1.4
retrieving revision 1.4.14.1
diff -C2 -d -r1.4 -r1.4.14.1
*** test_threaded_import.py 30 Aug 2001 05:16:13 -0000 1.4
--- test_threaded_import.py 22 Feb 2002 13:29:32 -0000 1.4.14.1
***************
*** 18,24 ****
critical_section.acquire()
N -= 1
! if N == 0:
! done.release()
critical_section.release()
# Tricky: When regrtest imports this module, the thread running regrtest
--- 18,28 ----
critical_section.acquire()
N -= 1
! # 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