Threading tips.
Gordon McMillan
gmcm at hypernet.com
Wed Jun 14 09:22:47 EDT 2000
Arinté wrote:
>Its me again with questions about my embedded python app. My scripts
>are primarily to talk to devices.
I read this as saying App calls Python reads device.
>If a script is running and the device
>does something, then I want the app to call the py script callback if
>one was set.
I read this as saying Python calls extension-that-read-devices calls back
into Python.
>Do I need to block the Python threads? What other steps
>do I need to take?
If that's an extension reading the device, it needs to
Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS so it doesn't block Python
while waiting on the device. If the callback is made on the same thread
that sent the extension off to read the device, everything should be fine.
If, however, you extension has created it's own thread, you need to create
a valid Python thread object for that new thread before it can call back
into Python. That is very advanced stuff.
- Gordon
More information about the Python-list
mailing list