Problems with thread state

Martin Sjögren martin at
Tue Jul 3 11:30:41 CEST 2001

Hello all

I'm trying to write an OpenSSL module for Python (purely in C) and I've
run into a big problem.

My understanding of the inner workings of Python isn't that big, so please
help me out here.

Seeing as a call to SSL_connect() might block, I surrounded the call to it
by Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. I also have a wrapper
callback for verification (i.e. I plug my callback into OpenSSL and it
calls a Python callback residing in a Context object)... Here's my
problem: When I call PyEval_CallObject() in my wrapper callback, python
segfaults! Some poking around with gdb shows that somewhere, before
PyFrame_New() is called to execute the Python callback in,
PyThreadState_Get() returns NULL!

When I comment out the Py_(BEGIN|END)_ALLOW_THREADS stuff, everything

What's wrong? What do I do about it?

Martin Sjögren
  martin at              ICQ : 41245059
  Phone: +46 (0)31 405242        Cell: +46 (0)739 169191
  GPG key:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 248 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list