[Python-checkins] CVS: python/dist/src/Lib/test test_thread.py,1.9,1.10 test_threaded_import.py,1.4,1.5
Tim Peters
tim_one@users.sourceforge.net
Fri, 15 Feb 2002 23:26:29 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30496/python/Lib/test
Modified Files:
test_thread.py test_threaded_import.py
Log Message:
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.10
diff -C2 -d -r1.9 -r1.10
*** test_thread.py 17 Jan 2001 21:51:36 -0000 1.9
--- test_thread.py 16 Feb 2002 07:26:27 -0000 1.10
***************
*** 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.5
diff -C2 -d -r1.4 -r1.5
*** test_threaded_import.py 30 Aug 2001 05:16:13 -0000 1.4
--- test_threaded_import.py 16 Feb 2002 07:26:27 -0000 1.5
***************
*** 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