Threads problem: the limbo_lock is making me cry

Tim Peters tim.one at home.com
Wed May 2 19:07:23 EDT 2001


[posted & mailed]

> Obligatory disclosure: I'm using Py2.0 on Win2K

Try Python 2.1 and see whether it persists.

> ...
> MainThread: <_ServerThread(Thread-2, stopped)>.join(): thread stopped
> Unhandled exception in thread:
> Traceback (most recent call last):
>   File "c:\python20\lib\threading.py", line 392, in __bootstrap
>     self.__delete()
>   File "c:\python20\lib\threading.py", line 401, in __delete
>     _active_limbo_lock.acquire()
> AttributeError: 'None' object has no attribute 'acquire'

MainThread does a .join() on all other (non-daemon) threads when Python is
shutting down.  This is arranged via an exit handler:

        atexit.register(self.__exitfunc)

in threading._MainThread.__init__.  2.1 fixed some race conditions here (both
in atexit.py, and in Python's shutdown sequence).

> This problem appears to go away if I include a time.sleep(1) after
> the end of the GUI event loop (when this ends, the program stops).

Says "race condition" to me -> try 2.1.

> I figure that I must be doing something stupid to see problems with
> _active_limbo_lock at all

Probably not your fault:  "it's impossible" for _active_limbo_lock to be
None, as it's set to a non-None value during threading.py's initialization.
Therefore, if you're seeing a None value at shutdown, it's most likely that
Python has somehow managed to tear down the threading module before the exit
handler has managed to run.  It's also possible that some other component is
your app is "illegally" calling into Python after Py_Finalize() was called.
But that could be very difficult to track down, so, again, try 2.1 first.





More information about the Python-list mailing list