[Pyrex] [Cython-dev] Callbacks from threads and PyGILState_Ensure/PyGILState_Release

Stefan Behnel stefan_ml at behnel.de
Sat Sep 22 18:24:33 CEST 2007


Greg Ewing wrote:
> Another way would be to write
> 
>   cdef void myfunc() nogil:
>     with GIL:
>       ...
> 
> and have Pyrex recognise 'with GIL' at the top level of
> the body as a special case and generate GIL-acquiring code
> around everything. I'm leaning towards this, because it
> would avoid introducing a notation that would become
> obsolete later with a smarter implementation.

Then we'd also have to disallow this for now:

    cdef int myfunc() nogil:
      with GIL:
          print("something")
      return 1 + 1

until we can move the decref stuff into the block and can decide if the rest
of the function is Python code free.

That makes the "with GIL" block pretty redundant.

Stefan



More information about the Pyrex mailing list