예제 #1
0
    manager.start()

    print('-' * 20)

    f1 = manager.Foo1()
    f1.f()
    f1.g()
    assert not hasattr(f1, '_h')

    print('-' * 20)

    f2 = manager.Foo2()
    f2.g()
    f2._h()
    assert not hasattr(f2, 'f')

    print('-' * 20)

    it = manager.baz()

    for i in it:
        print('<%d>' % i, end=' ')

    print()

##

if __name__ == '__main__':
    freezeSupport()
    test()
예제 #2
0
    done_queue = Queue()

    # Submit tasks
    list(map(task_queue.put, TASKS1))

    # Start worker processes
    for i in range(NUMBER_OF_PROCESSES):
        Process(target=worker, args=(task_queue, done_queue)).start()

    # Get and print results
    print('Unordered results:')
    for i in range(len(TASKS1)):
        print('\t', done_queue.get())

    # Add more tasks using `put()` instead of `putMany()`
    for task in TASKS2:
        task_queue.put(task)

    # Get and print some more results
    for i in range(len(TASKS2)):
        print('\t', done_queue.get())

    # Tell child processes to stop
    for i in range(NUMBER_OF_PROCESSES):
        task_queue.put('STOP')


if __name__ == '__main__':
    freezeSupport()
    test()
예제 #3
0
    print()

    print('\n\t######## testing threading.Lock\n')
    test_lockspeed(threading.Lock())
    print('\n\t######## testing threading.RLock\n')
    test_lockspeed(threading.RLock())
    print('\n\t######## testing processing.Lock\n')
    test_lockspeed(processing.Lock())
    print('\n\t######## testing processing.RLock\n')
    test_lockspeed(processing.RLock())
    print('\n\t######## testing lock managed by server process\n')
    test_lockspeed(manager.Lock())
    print('\n\t######## testing rlock managed by server process\n')
    test_lockspeed(manager.RLock())

    print()

    print('\n\t######## testing threading.Condition\n')
    test_conditionspeed(threading.Thread, threading.Condition())
    print('\n\t######## testing processing.Condition\n')
    test_conditionspeed(processing.Process, processing.Condition())
    print('\n\t######## testing condition managed by a server process\n')
    test_conditionspeed(processing.Process, manager.Condition())

    gc.enable()

if __name__ == '__main__':
    processing.freezeSupport()
    test()
예제 #4
0
    print()

    print('\n\t######## testing threading.Lock\n')
    test_lockspeed(threading.Lock())
    print('\n\t######## testing threading.RLock\n')
    test_lockspeed(threading.RLock())
    print('\n\t######## testing processing.Lock\n')
    test_lockspeed(processing.Lock())
    print('\n\t######## testing processing.RLock\n')
    test_lockspeed(processing.RLock())
    print('\n\t######## testing lock managed by server process\n')
    test_lockspeed(manager.Lock())
    print('\n\t######## testing rlock managed by server process\n')
    test_lockspeed(manager.RLock())

    print()

    print('\n\t######## testing threading.Condition\n')
    test_conditionspeed(threading.Thread, threading.Condition())
    print('\n\t######## testing processing.Condition\n')
    test_conditionspeed(processing.Process, processing.Condition())
    print('\n\t######## testing condition managed by a server process\n')
    test_conditionspeed(processing.Process, manager.Condition())

    gc.enable()

if __name__ == '__main__':
    processing.freezeSupport()
    test()