Exemplo n.º 1
0
    def _synchronize(obj, eng):
        queue = MyTimeoutQueue()
        # spawn a pool of threads, and pass them queue instance
        for i in range(len(args) - 1):
            t = MySpecialThread(queue)
            t.setDaemon(True)
            t.start()

        for func in args[0:-1]:
            if isinstance(func, list) or isinstance(func, tuple):
                new_eng = eng.duplicate()
                new_eng.setWorkflow(func)
                queue.put(lambda: new_eng.process([obj]))
            else:
                queue.put(lambda: func(obj, eng))

        # wait on the queue until everything has been processed
        queue.join_with_timeout(timeout)

        # run the last func
        args[-1](obj, eng)
Exemplo n.º 2
0
    def _synchronize(obj, eng):
        queue = MyTimeoutQueue()
        # spawn a pool of threads, and pass them queue instance
        for i in range(len(args) - 1):
            t = MySpecialThread(queue)
            t.setDaemon(True)
            t.start()

        for func in args[0:-1]:
            if isinstance(func, list) or isinstance(func, tuple):
                new_eng = eng.duplicate()
                new_eng.setWorkflow(func)
                queue.put(lambda: new_eng.process([obj]))
            else:
                queue.put(lambda: func(obj, eng))

        # wait on the queue until everything has been processed
        queue.join_with_timeout(timeout)

        # run the last func
        args[-1](obj, eng)