Problems with thread state

Martin Sjögren martin at strakt.com
Tue Jul 3 05:30:41 EDT 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
works.

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

-- 
Martin Sjögren
  martin at strakt.com              ICQ : 41245059
  Phone: +46 (0)31 405242        Cell: +46 (0)739 169191
  GPG key: http://www.strakt.com/~martin/gpg.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 248 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20010703/6e0e2ee2/attachment.sig>


More information about the Python-list mailing list