[Python-bugs-list] [ python-Bugs-516372 ] test_thread: unhandled exc. in thread

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Feb 2002 23:27:51 -0800


Bugs item #516372, was opened at 2002-02-12 02:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516372&group_id=5470

Category: Threads
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Armin Rigo (arigo)
Assigned to: Tim Peters (tim_one)
Summary: test_thread: unhandled exc. in thread

Initial Comment:
test_thread.py occasionally dumps a "Unhandled 
exception in thread" traceback at the last thread 
line "mutex.release()" about NoneType not having a 
release attribute. The problem is confusing for users 
thinking that something went wrong with the test 
(althought the regrtest suite doesn't detect such 
exceptions and tells that the test passed --- this 
could be another bug report BTW).

The problem shows up with Psyco but could also appear 
on plain Python executions depending on the precise 
timing. It comes from the fact that the thread code 
ends with:

 ...
   done.release()
   mutex.release()

where these two are mutexes. The main program ends 
with:

 ...
   done.acquire()
   print "All tasks done"

so if 'done' is released, the main program may exit 
before the thread has a chance to release 'mutex', 
which happens to be a global variable that the Python 
module-unloading logic will replace with None.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-02-15 23:27

Message:
Logged In: YES 
user_id=31435

Hmm.  You must be running on Linux.  I agree with your 
analysis, but I'll never see it on uniprocessor Windows:  
when the main thread goes away on Windows, child threads 
don't get another cycle.  I've seen other races "like this" 
pop up only on Linux -- it seems that Linux is uniquely 
slothful when killing off child threads.

Anyway, I appreciate the analysis and have fixed the 
problems:

Lib/test/test_thread.py; new revision: 1.10
Lib/test/test_threaded_import.py; new revision: 1.5

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-02-15 23:06

Message:
Logged In: YES 
user_id=31435

Changed Category to "Threads" and assigned to me.

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2002-02-14 11:37

Message:
Logged In: YES 
user_id=4771

The problem is not specific to Psyco, as it actually showed 
up once with Python only in test_threaded_import, which 
exhibits a similar behavior.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=516372&group_id=5470