This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Random errors on interpreter shutdown
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, gvanrossum, jcea, lobais
Priority: normal Keywords:

Created on 2008-01-03 23:28 by lobais, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg59174 - (view) Author: Thomas Dybdahl Ahle (lobais) Date: 2008-01-03 23:28
I have a pygtk program, that uses a fairly lot of threads in a pool. All
of these threads are setDaemon to ensure the application shuts down when
I call gtk.main_quit()

About every second time I close the app, I get one or more errors from
places in the program where a thread seams to have woken up, and now
find all attributes None.

This time I even got a message relating til the GIL:

...
for errortype in (IOError, LogOnError, socket.error, EOFError):
exceptions.AttributeError 'NoneType' object has no attribute 'error'
python: Python/pystate.c:497: PyGILState_Ensure: Assertion (assertion)
'autoInterpreterState' failed.
Afbrudt (SIGABRT)

the socket reference simply comes from "import socket" in the beginning
of the module.

As the errors only occur during application shutdown, it has no
practical effect, but it confuses users to post tons of bug reports.
msg59178 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2008-01-03 23:42
This has been fixed in 2.6, see revision 57216.
We won't be fixing this in 2.4, although a vendor might consider this.

Should we be fixing this in 2.5?
msg59194 - (view) Author: Thomas Dybdahl Ahle (lobais) Date: 2008-01-04 00:39
The fix looks nice.
I'll just implement it locally in my app for python < 2.4.

Thanks
msg59207 - (view) Author: Thomas Dybdahl Ahle (lobais) Date: 2008-01-04 01:33
I run this now in the beginning of my code. As far as I can see it works
fine.

if not hasattr(Thread, "_Thread__bootstrap_inner"):
    class SafeThread (Thread):
        def encaps(self):
            try:
                self._Thread__bootstrap_inner()
            except:
                if self.__daemonic and sys_ is None:
                    return
                raise
    setattr(SafeThread, "_Thread__bootstrap_inner",
SafeThread._Thread__bootstrap)
    setattr(SafeThread, "_Thread__bootstrap", SafeThread.encaps)
    threading.Thread = SafeThread
msg59591 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2008-01-09 12:48
The fix has been applied (by GvR) to 2.5 in r59724.

This issue can probably be closed now.
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46072
2008-01-16 02:47:25jceasetnosy: + jcea
2008-01-09 19:09:13gvanrossumsetstatus: open -> closed
resolution: fixed
2008-01-09 12:48:13akuchlingsetnosy: + akuchling
messages: + msg59591
2008-01-04 01:33:47lobaissetmessages: + msg59207
2008-01-04 00:39:03lobaissetmessages: + msg59194
2008-01-03 23:42:29gvanrossumsetnosy: + gvanrossum
messages: + msg59178
2008-01-03 23:28:41lobaiscreate