global interpreter lock not working as it should

Just just at xs4all.nl
Tue Jul 30 03:52:52 EDT 2002


In article <mailman.1028010823.7799.python-list at python.org>,
 martin at v.loewis.de (Martin v. Loewis) wrote:

> anton wilson <anton.wilson at camotion.com> writes:
> 
> > The reason your code works is because you explicitly give up the CPU
> > with the sleep calls. If you remove both time.sleep calls the results will 
> > look like:
> 
> I see. Now, I take the modified script
> 
> import threading, time
> 
> def func1():
>     for i in range(10):
>         for k in range(10):
>             pass
>         print "FUNC1"
> 
> def func2():
>     for i in range(10):
>         for k in range(10):
>             pass
>         print "FUNC2"
> 
> t = threading.Thread(target=func1)
> t.start()
> func2()
> 
> This has no explicitly-blocking calls, and prints
> 
> FUNC2
> FUNC2
> FUNC1
> FUNC2
> FUNC1
> FUNC2
> FUNC1
> FUNC2
> FUNC1
> FUNC2
> FUNC2
> FUNC2
> FUNC2
> FUNC2
> FUNC1
> FUNC1
> FUNC1
> FUNC1
> FUNC1
> FUNC1
> 
> So I still can't see your problem.

I can see it on MacOSX, three different Linux boxes and a FreeBSD box. 
Various Python versions. The output is always sequential.

Just



More information about the Python-list mailing list