Esempio n. 1
0
class AnotherReactor(threading.Thread):
    def __init__(self, port, type):
        threading.Thread.__init__(self)
        self._acceptor = Acceptor(HttpConnection)
        self._reactor = Reactor(select_type = type)
        if not self._reactor.open():
            print("reactor open failed")
        self._acceptor.open(("127.0.0.1", port), self._reactor)

    def run(self):
        while True:
            if not self._reactor.handle_events():
                break
        print("another reactor exit")
Esempio n. 2
0
    if cancel_timerid < 0:
        print("schedule timer failed") 
    else:
        print("schedule %s in [%s] ok" % ('cancel-4.5-2', datetime.now()))

    timerid = g_reactor.schedule_timer(TimerTest(), ('once-4-2', 'once'), 4, 2)
    if timerid < 0:
        print("schedule timer failed") 
    else:
        print("schedule %s in [%s] ok" % ('once-4-2', datetime.now()))

    timerid = g_reactor.schedule_timer(TimerTest(), ('once-4', 'delay'), 4)
    if timerid < 0:
        print("schedule timer failed") 
    else:
        print("schedule %s in [%s] ok" % ('once-4', datetime.now()))

    reset_timerid = g_reactor.schedule_timer(TimerTest(), ('loop-reset-3-3', 'reset'), 3, 3)
    if reset_timerid < 0:
        print("schedule timer failed") 
    else:
        print("schedule %s in [%s] ok" % ('loop-reset-3-3', datetime.now()))

    count = 0
    reset = 0
    canceled  = 0
    import sys
    while True:
        if not g_reactor.handle_events(): 
            sys.exit(0)