On Oct 21, 5:09 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Tue, 21 Oct 2008 04:58:00 -0200, Piotr Sobolewski  
> <[EMAIL PROTECTED]> escribió:
>
> > But what about my main question? Is it possible to release GIL without
> > sleeping? I know that in this example situation I can achieve my goals
> > without that - I can just move sleep outside of locked block. But I
> > just want to know it for future - can I just do something like
> > thread.gil_release()?
>
> No, you can't release the GIL *and* continue executing Python code.

I don't think that's what the OP was asking about; I think he merely
wanted to force a GIL release to give the other thread a chance to
run.

Reason being: in his code the lock was re-acquired right after it was
released.  This meant that the same thread that released the lock
almost always acquired it right back, since there was only a tiny
window in which a thread switch could take place.  Obviously the
wisdom of what he was doing was suspect, but the OP was right in that
a manual GIL release would allow a thread switch and could have helped
avoid starvation in that case.


Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to