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_sync_call(timeout): ee = QueueEventEngine() client = EventRPCClient(ee, 'test') server = EventRPCServer(ee, 'test') server.register("server_print_hello", server_print_hello) ee.start() print client.sync_call("server_print_hello", { 'msg': 'sync_client'}, timeout), "**" ee.stop() return
def test_sync_call(timeout): ee = QueueEventEngine() client = EventRPCClient(ee, 'test') server = EventRPCServer(ee, 'test') server.register("server_print_hello", server_print_hello) ee.start() print client.sync_call("server_print_hello", {'msg': 'sync_client'}, timeout), "**" ee.stop() return