def run(): while 1: if Bridge().get_status(): time.sleep(config.TIMER_CHECKER_INTERVAL) try: process() except KeyboardInterrupt: Bridge().close_connect() break except: timer_logger.error('exc occur.', exc_info=True) Bridge().close_connect() break else: Bridge().get_connect()
def web_connect(): Bridge(pro_name='web_server') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mjango.settings") from django.conf import settings settings.BASE_DIR while 1: # 应该会有性能问题,先写着,到时候看看 if Bridge().get_status(): try: time.sleep(1) except KeyboardInterrupt: Bridge().close_connect() break except: logger.error('error\n', exc_info=True) Bridge().close_connect() break else: Bridge().get_connect()
def bridge_to_users(uins, cmd, request, broadcast=False): if broadcast: uin_list = None cmd = dict(op_cmd=1000, send_cmd=cmd, uin_list=uin_list) else: if not isinstance(uins, list): uin_list = [uins] else: uin_list = uins cmd = dict(op_cmd=999, send_cmd=cmd, uin_list=uin_list) Bridge().send_data(cmd, request)
def run(): # 注册module module_register() job.add_listener(err_listener, EVENT_JOB_ERROR | EVENT_JOB_MISSED) job.start() while 1: # 应该会有性能问题,先写着,到时候看看 if Bridge().get_status(): try: time.sleep(1) except KeyboardInterrupt: Bridge().close_connect() break except: sche_logger.error('error\n', exc_info=True) Bridge().close_connect() break else: Bridge().get_connect()
def handle(self, *args, **options): Bridge(pro_name='timer_server') run()
def celery_to_users(uins, cmd, request): Bridge().get_connect() bridge_to_users(uins, cmd, request) Bridge().close_connect()
def bridge_to_other_game(cmd, request): Bridge().send_data(cmd, request)
def handle(self, *args, **options): Bridge(pro_name='schedule_server') run()