Delivering data to python from a c-thread
steve at holdenweb.com
Wed Nov 8 19:55:51 CET 2006
Svein Seldal wrote:
> Steve Holden wrote:
>> 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?
> Well yeah, in principle. However one would need some synchronization
> mechanisms anyway. The C data source is generating asynch. messages to
> deliver to python and thus the py thread must be ready to wait for it.
> It will add another thread in the total application (cuz' I cant remove
> the extra C thread since it has other important tasks), but I'll give it
> a shot at least!
OK. I was just thinking that, with Python threads, communication using
Queue.Queue is thread-safe and will handle the GIL, so that way you only
have the problem of how to synchronize your C code when it receives the
callback from the Python thread.
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