Пример #1
0
def test_count_to_100():
    # Define processes
    timer = Timer()
    timer.timer = timer.make_port("timer")

    consumer = Consumer()
    producer = Producer(timer, to=consumer)
    supervisor = Supervisor(timer.timer, children=[producer, consumer])

    # Define reactors
    loop = LoopReactor(processes=[consumer, producer, supervisor])
    timer_loop = TimedReactor(processes=[timer])

    emp = Emperor(children=[loop, timer_loop])
    supervisor.set_emperor(emp)

    supervisor.start()
    timer.start()

    emp.start()
    emp.join()

    assert True
Пример #2
0
    for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP):
        signal.signal(sig, signal_stop_handler)


if __name__ == "__main__":
    # Configure logging
    logging.basicConfig(format="%(levelname)s -- %(message)s", level=logging.INFO)

    # Define actors
    timer = Timer()
    root = Supervisor(timer.timer_proxy())
    consumer = Consumer()
    producer = Producer(timer.timer_proxy())
    producer.connect("out", consumer, "in")

    root.start()
    timer.start()
    root.spawn(consumer)
    root.spawn(producer)

    # Define reactors
    loop = LoopReactor(processes=[consumer, producer, root])
    timer_loop = TimedReactor(processes=[timer])

    emp = Emperor(children=[loop, timer_loop])
    register_stop_signal(root, emp)

    emp.start()
    emp.join()

Пример #3
0
    for sig in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP):
        signal.signal(sig, signal_stop_handler)


if __name__ == "__main__":
    # Configure logging
    logging.basicConfig(format="%(levelname)s -- %(message)s",
                        level=logging.INFO)

    # Define actors
    timer = Timer()
    root = Supervisor(timer.timer_proxy())
    consumer = Consumer()
    producer = Producer(timer.timer_proxy())
    producer.connect("out", consumer, "in")

    root.start()
    timer.start()
    root.spawn(consumer)
    root.spawn(producer)

    # Define reactors
    loop = LoopReactor(processes=[consumer, producer, root])
    timer_loop = TimedReactor(processes=[timer])

    emp = Emperor(children=[loop, timer_loop])
    register_stop_signal(root, emp)

    emp.start()
    emp.join()