Calling into Python from a C thread

Christian Heimes lists at cheimes.de
Mon Feb 9 14:35:14 EST 2009


Philip Semanchuk wrote:
> I didn't know there *was* such a thing. Thanks for the tip! For those
> who might be interested, the list is here:
> http://mail.python.org/mailman/listinfo/capi-sig
> 
> 
> FYI, I got my code working and it is in the latest release of posix_ipc:
> http://semanchuk.com/philip/posix_ipc/
> 
> The function MessageQueue_request_notification() does some necessary
> setup and the function process_notification() does the rest of the work.

Let me guess. You either forgot to start Python's threading system or
you didn't register you thread with Python. You need to deal with
PyThread_init_thread(), PyEval_InitThreads(), PyThreadState_New(),
PyThreadState_Clear() and PyThreadState_DeleteCurrent(). The module
Modules/threadmodule.c contains some examples.

Christian




More information about the Python-list mailing list