Delivering data to python from a c-thread

Svein Seldal svein at seldal dot com
Wed Nov 8 14:50:49 CET 2006


I have a C-application that calls a Python function main(). This 
function will loop forever and not return until the entire application 
is about to terminate.

In a parallel C-thread, some data must be regularly delivered to the 
running python application. My initial plan was to call a py function 
deliver() from this thread, however I constantly run into troubles. I 
keep getting a "Fatal Python error: ceval: tstate mix-up" error from 
python, even when I handle the GIL with PyGILState_Ensure().

I fail to use PyEval_AcquireLock() prior to python call either, as the 
main app would then constantly keep this lock when its running 
permanently in python.

Basically I would the thread to stop the execution of the main py app, 
call the message function deliver(). When the function returns from 
python, resume the execution of the main pyapp.

Svein Seldal

More information about the Python-list mailing list