no current thread warning

Guido van Rossum guido at python.org
Fri Dec 15 15:11:45 EST 2000


Charles Crain:

> I, like many before me, and writing a python C module that wraps a library
> that issues callbacks from a thread created from within C.  I have, of
> necessity, become acquainted with all the
> PyThreadState/PyEval_AcquireThread(), etc. stuff in order to do this without
> crashing the interpreter.
> 
> However, I am disturbed by the following warning, which is issued whenever
> one makes certain calls into the threading module from a callback within
> python:
> 
> "currentThread(): no current thread for XXXX", where XXXX (I presume) is a
> thread id.
> 
> Near as I can tell, this relates to the statement in the documentation for
> the threading.currentThread() function, which states something to the effect
> of "for threads not created by the threading module, a dummy thread with
> limited capabilities will be created."
> 
> A have a couple questions regarding this:
> 1.  Exactly how are the capabilities limited?  Are there any gotchas I
> should be on the lookout for?
> 2.  Why is the warning printed out unconditionally?  IMHO, it should only be
> printed out if the error is potentially fatal, and/or amounts to an asserion
> failure within the interpreter.  If I interpret the dox correctly, this
> message could at best be considered an informational, and should therefore
> be able to be turned off.  It is only cosmetic, but in considering whether
> to commercially release products we have written in Python, it is an issue.

Guilty as charged.  That warning was merely a debugging aid that stuck
around by mistake!  You can safely ignore it or comment it out; I'll
remove it from the next release.

The limitations of dummy threads are explained in a comment in
threading.py:

# Dummy thread class to represent threads not started here.
# These aren't garbage collected when they die,
# nor can they be waited for.
# Their purpose is to return *something* from currentThread().
# They are marked as daemon threads so we won't wait for them
# when we exit (conform previous semantics).

--Guido van Rossum (home page: http://www.python.org/~guido/)




More information about the Python-list mailing list