Delivering data to python from a c-thread

Steve Holden steve at holdenweb.com
Wed Nov 8 17:47:31 CET 2006


Svein Seldal wrote:
> Hi,
> 
> 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.
> 

Could you have the Python code create a second Python thread and have it 
call back into the C code to collect any waiting data?

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list