8 May 2013 20:09
[Cython] nogil doesn't seem to work when defined on extern cpp functions
Hello,
I ran into an interesting problem today. It doesn't seem like Cython respects the `nogil` statement on extern cpp functions. I am trying to use a blocking I/O function, and am running it in secondary thread so I can use another library function to cancel it.
I have tried it both on the `extern` line:
cdef extern from "digitalpersona/dpfp_api.h" nogil:
uint32_t DPFPGetEvent(dp_uid_t* pDevUID, dp_device_event_t** ppEvent, uint32_t uTimeoutMsec)
and on the function itself:
cdef extern from "digitalpersona/dpfp_api.h" nogil:
uint32_t DPFPGetEvent(dp_uid_t* pDevUID, dp_device_event_t** ppEvent, uint32_t uTimeoutMsec) nogil
Either way, this statement still blocks other threads:
res = dpfp_api.DPFPGetEvent(pIdDev, &pEvent, dpfp_api.DP_TIMEOUT_INFINITE)
While this statement does not:
with nogil:
res = dpfp_api.DPFPGetEvent(pIdDev, &pEvent, dpfp_api.DP_TIMEOUT_INFINITE)
All variables used (res, pIdDev, pEvent) are C variables.
Obviously this is not a huge issue, as I can bypass the GIL using `with nogil`. But I figured it would be a good idea to report it anyway.
Ryan Pessa
AerisPOS Project Manager / Developer
Essential Elements | AerisPOS
<div><div dir="ltr">Hello,<div><br></div> <div>I ran into an interesting problem today. It doesn't seem like Cython respects the `nogil` statement on extern cpp functions. I am trying to use a blocking I/O function, and am running it in secondary thread so I can use another library function to cancel it.</div> <div><br></div> <div>I have tried it both on the `extern` line:</div> <div> cdef extern from "digitalpersona/dpfp_api.h" nogil:</div> <div> uint32_t DPFPGetEvent(dp_uid_t* pDevUID, dp_device_event_t** ppEvent, uint32_t uTimeoutMsec)</div> <div>and on the function itself:</div> <div> <div> cdef extern from "digitalpersona/dpfp_api.h" nogil:</div> <div> uint32_t DPFPGetEvent(dp_uid_t* pDevUID, dp_device_event_t** ppEvent, uint32_t uTimeoutMsec) nogil</div> </div> <div><br></div> <div>Either way, this statement still blocks other threads:</div> <div> res = dpfp_api.DPFPGetEvent(pIdDev, &pEvent, dpfp_api.DP_TIMEOUT_INFINITE)</div> <div>While this statement does not:</div> <div> with nogil:</div> <div> <div> res = dpfp_api.DPFPGetEvent(pIdDev, &pEvent, dpfp_api.DP_TIMEOUT_INFINITE)</div> <div>All variables used (res, pIdDev, pEvent) are C variables.</div> <div><br></div> <div> Obviously this is not a huge issue, as I can bypass the GIL using `with nogil`. But I figured it would be a good idea to report it anyway.</div> <div> <p><span>Ryan Pessa</span><br><span>AerisPOS Project Manager / Developer</span><br><a href="http://www.essential-elements.net/" target="_blank"><span>Essential Elements</span></a> | <a href="http://www.aerispos.com/" target="_blank"><span>AerisPOS</span></a></p> </div> </div> </div></div>
So as the version changes it needs to be changed in the recipes:
Regards,
Thomas
Am 26.04.2013 08:34 schrieb Stefan Behnel:
> Hi,
>
> the packages in the Ubuntu PPA still have 0.18.0 in their name, although
> they actually build the current master, which is at 0.19.
>
> Is there a way to adapt that automatically?
>
> Stefan
>
RSS Feed