On Thu, 2005-07-07 at 13:48 -0400, Tom Cocagne wrote:
I was wondering if anyone has suggestions for a good way to go about setting up a message-passing communication channel between one or more C threads and a single thread dedicated to running Python/Twisted. I already have functional Python bindings accessing the contents of the messages (basically C structures) but need some way to exchange the messages between the C threads and the Python thread.
Any reason you're using threads? You can run Twisted directly on the glib event loop, so your whole program could run on the same loop. In any case, Switching data from Twisted to C is just like passing data from any Python program to C code: call a C extension function from Python that calls into C code, and for reverse call a Python function from C code. Thread safety is mostly orthogonal, so you can probably use the standard Twisted reactor.callFromThread to have code run in the Twisted thread.