Fatal Python error: PyThreadState_Get: no current thread with extension module

Tim Peters tim.one at comcast.net
Mon Jul 8 00:01:02 EDT 2002


[Mike C. Fletcher]
> I'm trying to compile a new extension module

Aha!  There's your problem <0.4 wink>.

> (based on mx.TextTools),  and I'm discovering that the programme gets a
> Fatal Python error after completing a test suite (likely during cleanup
> of the various modules).
>   I'm trying to figure out what the error really means, and in which
> crack I should put my finger to stop the dike from bursting.  Is there a
> guide/guidelines/helpful-elf-who-sneaks-into-the-shop-at-night for
> debugging this kind of error anywhere?

No, these are hard, but if Python didn't produce this message, your program
would die nanoseconds later with a NULL-pointer dereference instead.

Are you using threads?  If so, the most likely cause is that some thread is
calling back into the Python interpreter (== calling a function in the
Python C API) without first acquiring the global interpreter lock.

You didn't say which version of Python you're using, but in older versions
it's also possibly due to a shutdown race that has since been fixed.  You
also didn't say which OS you're using, and assorted races in practice have
historically been strongly correlated with OS due to differences in their
native thread scheduling (e.g., Windows is much happier to swap threads
frequently than is Linux, and some races discovered on the one proved
impossible to provoke on the other).

If you're not using threads, you've got a real mystery on your hands.

just-another-reason-it-sucks-to-be-you-if-so<wink>-ly y'rs  - tim






More information about the Python-list mailing list