I wrap a C function that performs a select operation and then processes incoming messages. I understand that when a C function is about to block, the correct way to call it when resolving other threads is:
Py_BEGIN_ALLOW_THREADS
blocking_function();
Py_END_ALLOW_THREADS
However, it happens that this function takes a callback pointer as a parameter. This callback is called to handle an incoming message that is pre-processed by C. I successfully completed this callback in a function that calls PyEval_CallObject()
, which allows me to pass it a Python callback.
Now, when I add thread support, I am wondering if this is possible at the same time:
- Release the GIL before invoking this blocking operation.
- This locking operation will safely call the python interpreter back.
Will this cause problems? If so, is there a way around it?
Thank.
Steve source
share