Ejemplo n.º 1
0
def test_main():
    # This takes about n/3 seconds to run (about n/3 clumps of tasks, times
    # about 1 second per clump).
    global numtasks
    numtasks = 10

    # no more than 3 of the 10 can run at once
    global sema
    sema = _threading.BoundedSemaphore(value=3)
    global mutex
    mutex = _threading.RLock()
    global running
    running = 0

    global threads
    threads = []

    starttasks()

    if verbose:
        print 'waiting for all tasks to complete'
    for t in threads:
        t.join()
    if verbose:
        print 'all tasks done'
Ejemplo n.º 2
0
 def setUp(self):
     self.numtasks = 10
     global sema
     sema = _threading.BoundedSemaphore(value=3)
     global mutex
     mutex = _threading.RLock()
     global running
     running = 0
     self.threads = []