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

Ulisses Furquim ulisses.silva at openbossa.org
Mon Sep 17 14:12:13 CEST 2007


Hi,

On 9/17/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Ulisses Furquim wrote:
> No, but I think most of the time we can check whether
> what he says he thinks he is doing is self-consistent.

Ok, I see what you're trying to do.

> I'm not trying to make Pyrex decide for itself when
> releasing the GIL would be a good idea -- just trying to
> arrange things so that, if the programmer does decide
> to do so, he's least likely to shoot himself in the foot
> as a result.

Yep, that'd be great, I just think that this implicit behavior
shouldn't be too confusing.

> There will certainly be something simpler to start with.
> I just want to make the simpler thing forward-compatible
> with something more elaborate later.

I agree.

> >     cdef void my_callback(void *data):
> >       with GIL:
> >         print "Called back!"
>
> Unfortunately, that doesn't quite work, because Pyrex
> generates increfs for args and locals before getting to
> the "with GIL:" statement. That's why the whole idea of
> having something in the function header got started.

Yep, I know that, we'd have to change the way Pyare generates code if
we would do this. I know this becuase I wanted such a construction to
solve my problem when I sent the first patch to annotate functions (I
thought it was easier than change Pyrex to have a block construction
like "with GIL").

Regards,

-- Ulisses



More information about the Pyrex mailing list