A possible bug in python threading/time module?

V

vm_usenet

Hi everyone,

I've been running this segment of code (slightly simplified to
emphasize the main part):

----START of Script----

import time
import threading

sem = threading.Semaphore(2048)

class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
sem.acquire()

def run(self):
j = 0
for i in range(1000):
j = j+1
time.sleep(60)
sem.release()

#main
for i in range(4096):
MyThread().start()

----END of Script----

I ran it on python 2.2.2 and python 2.3b1, and on both all of the
threads started successfully, acquiring the semaphore until 0
resources were left.
However, about 10-20 threads remain active after a while (and the
semaphore is lacking resources, respectively). I waited for about two
hours, and nothing changed - it appears to be hanging. Did anyone
encounter this behaviour before?
Am I the only one who ran into this situation? Is this a bug?

Thanx in advance

vm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top