Does the Python/C interface support Queue objects?

S

scott.manton

I'm a new user of the Python C interface. I would like to know if it
is possible to put items on a standard python Queue object in C, and
pop them from Python. Does the Python/C interface support Queue
objects?

A little background. I made a C dll that sets up a thread for
collecting data from an NI data aquisition card. The thread builds a
list and passes the list to to python via a callback, then python puts
them in the Queue. I would prefer to put the data in the Queue from
the C thread for efficiency, and then monitor the Queue from python.
 
F

Fredrik Lundh

A little background. I made a C dll that sets up a thread for
collecting data from an NI data aquisition card. The thread builds a
list and passes the list to to python via a callback, then python puts
them in the Queue. I would prefer to put the data in the Queue from
the C thread for efficiency, and then monitor the Queue from python.

the Queue type is implemented in Python, so you won't gain much by
skipping the callback.

but if you insist, you can use the abstract API to manipulate the queue
object:

http://docs.python.org/api/object.html

res = PyObject_CallMethod(queue, "put", "O", object);
... check error status ...
Py_DECREF(res);

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top