Ejemplo n.º 1
0
 def _process(self, event):
     """ 基于多线程的处理事件 """
     if event.route not in self._routes:
         log.warning("事件%s 没有被处理" % event.route)
         return
     for handler in self._routes[event.route]:
         try:
             log.debug("处理事件%s" % event.route)
             thread.start_new_thread(handler, (event,))
             #handler(event)    
         except Exception as e:
             log.error(e)
Ejemplo n.º 2
0
 def _process(self, event):
     """ 基于多线程的处理事件 """
     if event.route not in self._routes:
         log.warning("事件%s 没有被处理" % event.route)
         return
     for handler in self._routes[event.route]:
         try:
             log.debug("处理事件%s" % event.route)
             _thread.start_new_thread(handler, (event, ))
             #handler(event)
         except Exception as e:
             log.error(e)
Ejemplo n.º 3
0
 def _process_apiback(self, event):
     assert(event.route == self.EVENT_FROM_SERVER)
     self._timeout = 0
     rid = event.args['rid']
     try:
         with self._handlers_lock:
             handler = self._handlers[rid]
     except KeyError:
         log.info('[RPCClient._process_apiback] 放弃超时任务的返回结果')
     else:
         try:
             if handler:
                 # 异步
                 handler(event.args['ret'])
             else:
                 # 同步
                 self._sync_ret = event.args['ret']
                 self._notify_server_data()
         except Exception as e:
             log.error(e)
         log.debug("[RPCClient._process_apiback] 删除已经完成的任务 rid; %s" % rid)
         with self._handlers_lock:
             del self._handlers[rid]
Ejemplo n.º 4
0
 def _process_apiback(self, event):
     assert (event.route == self.EVENT_FROM_SERVER)
     self._timeout = 0
     rid = event.args['rid']
     try:
         with self._handlers_lock:
             handler = self._handlers[rid]
     except KeyError:
         log.info('[RPCClient._process_apiback] 放弃超时任务的返回结果')
     else:
         try:
             if handler:
                 # 异步
                 handler(event.args['ret'])
             else:
                 # 同步
                 self._sync_ret = event.args['ret']
                 self._notify_server_data()
         except Exception as e:
             log.error(e)
         log.debug("[RPCClient._process_apiback] 删除已经完成的任务 rid; %s" % rid)
         with self._handlers_lock:
             del self._handlers[rid]