Re: I want to release the GIL

2008-10-21 Thread Martin v. Löwis
> When I run it, I notice that only one thread works and the other one > never has a chance to run. I guess it is because the thread don't > have a chance to release the GIL This guess is wrong. A call to lock.acquire *does* release the GIL, (as does the call to thread.sleep, as somebody else poi

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
On Oct 21, 7:49 am, MRAB <[EMAIL PROTECTED]> wrote: > On Oct 21, 10:22 am, Carl Banks <[EMAIL PROTECTED]> wrote: > > > 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ó: > > > > >

Re: I want to release the GIL

2008-10-21 Thread MRAB
On Oct 21, 10:22 am, Carl Banks <[EMAIL PROTECTED]> wrote: > 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 wit

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
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

Re: I want to release the GIL

2008-10-21 Thread Carl Banks
On Oct 21, 1:12 am, Piotr Sobolewski <[EMAIL PROTECTED]> wrote: > Hello, > I have such program: > > import time > import thread > def f(): >     global lock >     while True: >         lock.acquire() >         print thread.get_ident() >         time.sleep(1) >         lock.release() > lock=thread.a

Re: I want to release the GIL

2008-10-21 Thread Gabriel Genellina
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 j

Re: I want to release the GIL

2008-10-21 Thread Diez B. Roggisch
Piotr Sobolewski schrieb: Thanks for answers. 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 j

Re: I want to release the GIL

2008-10-21 Thread k3xji
See yield() statement. -- http://mail.python.org/mailman/listinfo/python-list

Re: I want to release the GIL

2008-10-21 Thread Piotr Sobolewski
Thanks for answers. 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

RE: I want to release the GIL

2008-10-20 Thread Delaney, Timothy (Tim)
Piotr Sobolewski wrote: > Hello, > I have such program: > > import time > import thread > def f(): >     global lock >     while True: >         lock.acquire() >         print thread.get_ident() >         time.sleep(1) >         lock.release() > lock=thread.allocate_lock() > thread.start_new_thre

Re: I want to release the GIL

2008-10-20 Thread Chris Rebert
On Mon, Oct 20, 2008 at 10:12 PM, Piotr Sobolewski <[EMAIL PROTECTED]> wrote: > Hello, > I have such program: > > import time > import thread > def f(): > global lock > while True: > lock.acquire() > print thread.get_ident() > time.sleep(1) > lock.release() >