def test_eventengine(): """测试函数""" import sys from datetime import datetime import time def simpletest(event): print str(datetime.now()), event.route ee = QueueEventEngine() timer = Timer(ee) ee.register(Event.TIMER, simpletest) ee.start() timer.start() time.sleep(2) timer.stop() time.sleep(2) timer.resume() try: while True: time.sleep(1) except KeyboardInterrupt: ee.stop() timer.stop() sys.exit(0)
def test_zmq_eventengine(): """测试函数""" import sys from datetime import datetime import time def simpletest(event): print str(datetime.now()), event.route print 'test_zmq_eventengine.....' ee = ZMQEventEngine() ee.register(Event.TIMER, simpletest) timer = Timer(ee) ee.start() timer.start() event = Event(route=Event.TIMER) ee.emit(event) ## @TODO test_unregister #time.sleep(2) #ee.stop_timer() #time.sleep(2) #ee.resume_timer() try: while True: time.sleep(1) except KeyboardInterrupt: timer.stop() ee.stop() sys.exit(0)