python's threading has no "interrupt"?

Jay O'Connor joconnor at
Tue Dec 2 18:55:53 CET 2003

Dennis Lee Bieber wrote:

> There's the first point of departure: Python threads (as long as you 
>aren't in a C language number crunching extension) are preemptive 
>scheduled, on something like a 10-20 byte-code interval. Cooperative 
>basically means /you/ had to handle the scheduling of threads; in 
>Python you don't, it happens automatically.

I stand corrected.  The following code behaves exactly like I would want 
it to rather than how I feared it would.  Is this a change?  I don't 
seem to recall the same result when I tried it initially with Python 

from threading import Thread

def test1():

    while True:
        print "test1"

def test2():
    while True:
        print "test2"

t1 = Thread (target=test1)
t2= Thread (target=test2)

print "starting"

print "started"

while  True:
        print "main"


More information about the Python-list mailing list