global interpreter lock not working as it should

Martin v. Loewis martin at v.loewis.de
Mon Jul 29 19:35:29 EDT 2002


anton wilson <anton.wilson at camotion.com> writes:

> I'm having a problem where the interpreter in ceval.c does not let
> threads run concurently. Any thread that holds the lock never gives
> up the lock until it has run to completion.

I don't believe that statement. Do you have an example program that
demonstrates you claims?

To demonstrate my point, consider

import threading, time

def func1():
    for i in range(3):
        print "FUNC1"
        time.sleep(1)

def func2():
    for i in range(3):
        print "FUNC2"
        time.sleep(1)

t = threading.Thread(target=func1)
t.start()
func2()

On my Linux system, it prints

FUNC2
FUNC1
FUNC1
FUNC2
FUNC2
FUNC1

Regards,
Martin



More information about the Python-list mailing list