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.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, gvanrossum, ronaldoussoren
Date 2007-11-23.23:34:29
SpamBayes Score 0.012723404
Marked as misclassified No
Message-id <1195860870.73.0.65481016459.issue1402@psf.upfronthosting.co.za>
In-reply-to
Content
I managed to reproduce the problem consistently with the following code:

import ctypes, sys, time, thread

# Module globals are cleared before __del__ is run
# So save the functions in class dict
class C:
    ensure = ctypes.pythonapi.PyGILState_Ensure
    release = ctypes.pythonapi.PyGILState_Release
    def __del__(self):
        state = self.ensure()
        self.release(state)

def waitingThread():
    x = C()
    time.sleep(100)

thread.start_new_thread(waitingThread, ())
time.sleep(1)
sys.exit(42)


On exit, PyInterpreterState_Clear stops the sleeping thread and free its
local variables. But at this time _PyGILState_Fini has already been
called...

The initial patch also corrects this problem. I join another patch,
which adds the above code in a testcase.

Ready to check-in, but can someone have a look?
Files
File name Uploaded
test_gilstate.patch amaury.forgeotdarc, 2007-11-23.23:34:29
History
Date User Action Args
2007-11-23 23:34:30amaury.forgeotdarcsetspambayes_score: 0.0127234 -> 0.012723404
recipients: + amaury.forgeotdarc, gvanrossum, ronaldoussoren
2007-11-23 23:34:30amaury.forgeotdarcsetspambayes_score: 0.0127234 -> 0.0127234
messageid: <1195860870.73.0.65481016459.issue1402@psf.upfronthosting.co.za>
2007-11-23 23:34:30amaury.forgeotdarclinkissue1402 messages
2007-11-23 23:34:29amaury.forgeotdarccreate