A possible bug in python threading/time module?

Discussion in 'Python' started by vm_usenet, Jul 2, 2003.

  1. vm_usenet

    vm_usenet Guest

    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
    vm_usenet, Jul 2, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Peters
    Replies:
    6
    Views:
    363
    vm_usenet
    Jul 6, 2003
  2. flamesrock
    Replies:
    8
    Views:
    449
    Hendrik van Rooyen
    Nov 24, 2006
  3. Replies:
    9
    Views:
    1,030
    Mark Space
    Dec 29, 2007
  4. Steven Woody
    Replies:
    0
    Views:
    404
    Steven Woody
    Jan 9, 2009
  5. Steven Woody
    Replies:
    0
    Views:
    444
    Steven Woody
    Jan 9, 2009
Loading...

Share This Page