def stop(self): """ 进程退出 """ if self.stoping: return self.stoping = True log.info(u'game模块停止') Game.parent_stoped = bool(os.environ.get('PARENT_STOPED', False)) def _stop_func(): try: self._stop() except StandardError: log.log_except() for mgr in self.stop_mgrs: try: mgr.stop() except StandardError as e: log.log_except('stop mgr(%s) error:%s', mgr, e) sleep(0.5) #允许其它线程切换 #等待其它完成 while self.stop_lock.wait() < self.lock_count: sleep(0.1) try: #保证在30分钟内处理完 with Timeout.start_new(60 * 30): _stop_func() except: log.log_except() self.stoped = True
def pay_back(self, rid, first_reward, coin): """ 支付回调 coin=奖励里的真元宝数""" reward = self._game.reward_mgr.get(rid) items = reward.reward(self.reward_params()) #是否首充 vip_base_coin = self._game.setting_mgr.setdefault( VIP_BASE_COIN, VIP_BASE_COIN_V) log.info("vipCoin:%s, charge origin:%s, first_reward:%s", self.data.vipCoin, vip_base_coin, first_reward) bag_items = self.bag.add_items(items, log_type=ITEM_ADD_PAY) if not self.data.Payed and first_reward: try: self.data.Payed = 1 freward = self._game.reward_mgr.get(first_reward) fitems = freward.reward(self.reward_params()) #发放首充奖励 log.info(u'[pay_back](%d)首冲翻倍:%s', self.data.id, coin) self.add_coin(aCoin3=coin, log_type=COIN_FIRST_PAY) bag_items.coin3 += coin self.vip.first_charge(fitems) except: log.log_except() self.vip.pay_back(bag_items) self.pub(MSG_VIP_COIN_ADD, self.data.coin2) return 1, self.data.level
def pub_exit(self): """ 进程准备退出 """ for (func, args, kw) in self._exits: try: func(*args, **kw) except: log.log_except()
def run(self): import game game.init(self) sys.modules['app'] = self self.names = None #subgame names self.sub_mgr = subgame.SubGameMgr(self) self.sub_mgr.start() self.rpc_svr.bind(self.admin_addr) self.rpc_svr.register(self) self.rpc_svr.start() self._init_web() self.web_svr.start() log.info('app started') while 1: try: self._waiter.wait() break except KeyboardInterrupt: log.info('app stoped:KeyboardInterrupt') except SystemExit: log.info('app stoped:SystemExit') except: log.log_except() break log.info('spawn app stop') spawn(self.stop) sleep(0.2) cmd = ' '.join(map(str, [sys.executable,] + sys.argv)) log.info('*****app(%s) stoped', cmd) self.stop() #守护进程方式,重启服务 if self.restarted and hasattr(self, 'daemon_runner'): self.daemon_runner.domain_restart()
def del_task(self, task): try: self.tasks.pop(task.data.id) self.tids.pop(task.data.tid) task.delete(self.player._game.rpc_store) except: log.log_except()#_better=1)
def player_login(self, pid): resp_f = 'enter' player_data = PlayerData.load(pid) player = Player() player.data.update(player_data) if player.data.id is None: log.error('player(%d)player_login load error:%s', pid, player_data) return pack_msg(resp_f, 0, err=errcode.EC_VALUE) if player.is_forbid_login: return pack_msg(resp_f, 0, err=errcode.EC_FORBID_LOGON) if not self.mgr.add_player(player): return pack_msg(resp_f, 0, err=errcode.EC_TIME_UNDUE) self.player = player try: player.set_rpc(self._rpc) player.login(self) map_id = player.data.mapId if player.data.mapId else 1 player.scene_enter(map_id, login=True) self.mgr.logon_player(player) log.debug(u'(%s)玩家(%s)登陆成功', player.data.id, player.data.name) player.send_msg(player.get_init_msg()) spawn(self.mgr.logoned_player, player) return pack_msg(resp_f, 1) except: log.log_except(u'玩家(%s)登陆初始化失败', player.data.id) self.player_logout() return pack_msg(resp_f, 0, err=errcode.EC_VALUE)
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 # log.info('[pp]PayCallBack:%s', data) for fn in cls.FIELDS: if fn not in data: log.warn('[pp]Param not found:%s', fn) return CODE_PARAM, '' #rsa验证 sign = data['sign'] sdata = sdk.decode_sign(sign) for k, v in sdata.iteritems(): if k == cls.F_STATUS: if int(data[k]) != int(v): return CODE_SIGN, 'sign data error' elif data[k] != v: return CODE_SIGN, 'sign data error' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, '' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def gm_add_ally_members(self, a_name, p_name, num): """添加同盟成员的数目""" if p_name: return self._add_member_by_p_name(a_name, p_name) try: rpc_store = self.player._game.rpc_store ally_mgr = Game.instance.rpc_ally_mgr sum_num = 0 #通过GM命令加入同盟的总数 lev_in_num = PlayerData.count({FN_PLAYER_LEVEL: { FOP_GTE: 1 }}) #达到等级条件的总数 us_list = [] #本次使用到了的pid #每个段的起始和结束pid[(s1,e1), (s2,e2))] section_list = [(i * SECTION, (i + 1) * SECTION) for i in xrange(lev_in_num / SECTION)] start_time = time.time() shuffle(section_list) if not ally_mgr.set_gm_ally_by_name(a_name): self.log(u'公会名字不存在') return for start_pid, end_pid in section_list: us_list.append((start_pid, end_pid)) for pid in xrange(start_pid, end_pid): if sum_num >= num: self.log(u'申请添加%s个满足等级条件的%s个实际添加%s个成员', num, lev_in_num, sum_num) ally_mgr.clear_gm_ally() return if not rpc_store.has("player", pid): log.info("table player has no pid:%s", pid) continue sum_num += ally_mgr.gm_add_ally(pid) except: log.log_except()
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 for attr in cls.FIELDS: if attr not in data: log.warn('[TongBu]Param not found:%s, data:%s', attr, data) return CODE_PARAM, '' #rsa验证 sign = data['sign'] sdata = sdk.get_sign(data) if sdata != sign: log.warn('[TongBu]sign data error, sign(%s) sdata(%s)', sign, sdata) return CODE_SIGN, 'sign data error' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, 'payExistError' #保存 try: if cls.save_data( data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), int(data[cls.F_PRICE])/100, data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 for attr in cls.FIELDS: if attr not in data: log.warn('[TongBu]Param not found:%s, data:%s', attr, data) return CODE_PARAM, '' #rsa验证 sign = data['sign'] sdata = sdk.get_sign(data) if sdata != sign: log.warn('[TongBu]sign data error, sign(%s) sdata(%s)', sign, sdata) return CODE_SIGN, 'sign data error' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, 'payExistError' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), int(data[cls.F_PRICE]) / 100, data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def check_accout(cls, sdk, data): player_info_fs = ['rid', 'level'] log.info('[idsc]Server:%s', data) ret_msg = None try: sid = int(data['serv_id']) name = data.get('usr_name') for sid, rpc_client in game_servers.iter_servers([sid]): u, p = rpc_client.get_rpc_user_by_name( name, player_fs=player_info_fs) ss = game_servers.get_servers() server = ss.get(sid) ret_msg = { "err_code": 0, "usr_id": u['name'], "usr_name": name, "usr_rank": p['level'], "player_id": p['id'], "app_id": server.app } except: log.log_except() if ret_msg is None: ret_msg = {'err_code': 1, 'desc': u'没有该用户'} return ret_msg
def http_urllib3(host, port, url, params=None, data=None, raise_err=False, headers=None, ssl=False): """ 用http方式发送数据 """ err_msg = '发送数据到HTTP服务器(%s:%s%s)时出错' % (host, port, url) try: urls = get_urls(host, port, url, params, ssl=ssl) data = urllib.urlencode(data) rs = _http_pool.urlopen('POST' if data is not None else 'GET', urls, body=data, headers=headers) if rs.status != 200: if raise_err: raise ValueError(rs.status, rs.data[:50]) log.error('%s:%s - %s', err_msg, rs.status, rs.data[:50]) else: return rs.data except socket.error as e: if raise_err: raise ValueError(e) log.error('%s:%s', err_msg, str(e)) except Exception: if raise_err: raise log.log_except()
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 rs = cls.check_attr(cls.FIELDS, data) if not rs: return CODE_PARAM, '' #rsa验证 sign = data['sign'] data = data['data'] sdata = sdk.get_sign(data) if sdata != sign: log.warn('[uc]sign data error, sign(%s) sdata(%s)', sign, sdata) return CODE_SIGN, 'sign data error' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, 'payExistError' #保存 try: if cls.save_data( data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def get_sub_mgr(self, pid, offline=False, forced=True): """ 获取玩家所在进程的player_mgr对象 @param: pid: 玩家id offline: 是否离线也选择一个子进程 forced: 是否离线也强制选一个 @return: app_name, rpc_sub_mgr """ self.lock.acquire() try: app_name = self._players.get(pid) ensure = False if not app_name and offline: ensure = True app_name = self._logouts.get(pid) if not app_name and forced: app_name, _ = self.choice_sub_mgr() if not app_name: self.lock.release() return '', None sub_mgr = Game.get_service(app_name, SubPlayerMgr._rpc_name_) if ensure: rs = sub_mgr.load_player(pid) if not rs: self.lock.release() return '', None else: self._logouts[pid] = app_name self.lock.release() return app_name, sub_mgr except: self.lock.release() log.log_except() return '', None
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 # log.info('[sdk91Pay]PayCallBack:%s', data) for fn in cls.FIELDS: if fn not in data: log.warn('[sdk91Pay]Param not found:%s', fn) return CODE_PARAM, '' #算md5需要用utf8编码 data_utf8 = dict([(k, v.encode('utf8')) for k, v in data.iteritems()]) sign = data['Sign'] sign_t = ''.join(['%%(%s)s' % fn for fn in cls.FIELDS[:-1]]) sign_str = '%s%s' % (sign_t % data_utf8, sdk.app_key) md5_str = md5(sign_str).hexdigest() if sign != md5_str: log.warn('[sdk91Pay]sign error:%s != %s (%s)', sign, md5_str, sign_str) return CODE_SIGN, '' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, '' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def del_task(self, task): try: self.tasks.pop(task.data.id) self.tids.pop(task.data.tid) task.delete(self.player._game.rpc_store) except: log.log_except() #_better=1)
def stop(self): log.info(u'主进程stop,关闭逻辑进程') for logic_app, (pid, game) in self.logics.items(): try: self._remove_logic(logic_app) except: log.log_except()
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 for fn in cls.FIELDS: if fn not in data: log.warn('[idsc]callback Param not found:%s', fn) return CODE_PARAM, '' #rsa验证 sign = data['sign'] sdata = sdk.get_pay_sign(data) if sdata != sign: log.warn('[idsc]callback sign data error, sign(%s) sdata(%s)', sign, sdata) return CODE_SIGN, 'sign data error' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 # log.info('[pp]PayCallBack:%s', data) for fn in cls.FIELDS: if fn not in data: log.warn('[pp]Param not found:%s', fn) return CODE_PARAM, '' #rsa验证 sign = data['sign'] sdata = sdk.decode_sign(sign) for k,v in sdata.iteritems(): if k == cls.F_STATUS: if int(data[k]) != int(v): return CODE_SIGN, 'sign data error' elif data[k] != v: return CODE_SIGN, 'sign data error' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, '' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def send_msg_by_token(self, uid, token, msg, **kw): if self.apns_started: try: log.info("identifier:%s,uid:%s,token:%s", kw['identifier'], uid, token) self.send_apns_msg(token, msg, **kw) except Exception, e: log.log_except()
def start(self): self.init_frame() self.frame.start() self._init_web() self.web_svr.start() log.info('app started') # spawn_later(2, self.stop) while 1: try: self._waiter.wait() break except KeyboardInterrupt: log.info('app stoped:KeyboardInterrupt') except SystemExit: log.info('app stoped:SystemExit') except: log.log_except() break log.info('spawn app stop') spawn(self.stop) sleep(0.2) cmd = ' '.join(list(map(str, [ sys.executable, ] + sys.argv))) log.info('*****app(%s) stoped', cmd) self.stop() #守护进程方式,重启服务 if self.restarted and hasattr(self, 'daemon_runner'): self.daemon_runner.domain_restart()
def GET(cls, sdk, data): """ 收到回调,处理数据 """ #校验 # log.info('[dpay]PayCallBack:%s', data) for fn in cls.FIELDS: if fn not in data: log.warn('[dpay]Param not found:%s', fn) return CODE_PARAM, '' #算md5需要用utf8编码 data_utf8 = dict([(k,v.encode('utf8')) for k,v in data.iteritems()]) sign = data['Sign'] sign_t = '&'.join(['%s=%%(%s)s' % (fn, fn) for fn in cls.FIELDS[:-1]]) sign_str = '%s%s' % (sign_t % data_utf8, sdk.app_key) if isinstance(sign_str, unicode): sign_str = sign_str.encode('ascii') md5_str = md5(sign_str).hexdigest() if sign != md5_str: log.warn('[dpay]sign error:%s != %s (%s)', sign, md5_str, sign_str) return CODE_SIGN, '' if cls.pay_exist(data[cls.F_TORDER]): return CODE_SUCC, '' #保存 try: if cls.save_data(data[cls.F_PORDER], data[cls.F_TORDER], cls.is_ok(data), data[cls.F_PRICE], data): return CODE_SUCC, 'save' except: log.log_except() return CODE_FAIL, 'systemError'
def _notice_data(self, l_sec): """ 广播数据 包括世界boss剩余血量和排名 """ #log.debug('(%s)WorldBoss_notice_data %s', self.data.blid, l_sec) hp_resp_f = 'bossHp' rank_resp_f = 'bossRank' hp_time = self.fetch_hp_time c = self.fetch_rank_time / hp_time sleep(l_sec) tmp = 0 self.is_start = is_win = True while not self.gm_stoped: sleep(hp_time) msg = pack_msg(hp_resp_f, 1, data={ 'hp': self.boss_hp, 'mhp': self.max_hp }) Game.rpc_player_mgr.player_send_msg(self.enter_pids, msg) #log.debug('world hp enter_pids %s %s', self.boss_hp, self.enter_pids) if self.boss_hp <= 0: break if self.boss_start + self.fetch_world_boss_times < time.time(): is_win = False break tmp += 1 if tmp != c: continue tmp = 0 rs, data = self._get_rank() #log.debug('world_rank %s', data) if not rs: continue msg = pack_msg(rank_resp_f, 1, data=data) Game.rpc_player_mgr.player_send_msg(self.enter_pids, msg) self.boss_mgr.w_start_boss = None log.debug('is_win------- %s, gm %s, join-player %s', is_win, self.gm_stoped, len(self.pid_hurts)) if self.gm_stoped: is_win = False #if is_win: #更改为不管怪物是否死都发奖励 try: #发放奖励 self._reward() #vip不参加也发奖励 self._reward_vip() except: log.log_except() #写入log 记录伤害 self._log_info() #清楚数据 self._clear_data() #记录数据 self.save_data(is_win) if self.boss_mgr.gm_wboss: self.boss_mgr.gm_wboss = False self.boss_mgr.gm_start = False self.gm_stoped = False
def stop(self): for n in reversed(self.union_names): # for app, (pid, name) in self.unions.items(): try: app = self.get_app(n) app.stop() except: log.log_except()
def reload(self): """ 动态加载chl_api,并继承 """ try: reload(chl_api) except StandardError: log.log_except() return BaseClient.__bases__ = (chl_api.ChannelApi, )
def sendReward(self): try: sleep(60) self.cal(log=1) self.sendToLogic() self._activity_reward() except: log.log_except()
def _runtimes_exec(self, name, func): for obj in self.runtimes.__dict__.values(): if name and not hasattr(obj, name): continue try: func(obj) except: log.log_except()
def _saveLoop(self): stime = 10 * 60 while True: sleep(stime) try: self.save() except: log.log_except()
def _loop(self): while 1: sleep(config.report_times) try: self.update_report() except socket.error as err: log.warn('socket error:%s', err) except: log.log_except()
def _logout(self): self.sit.close() for obj in self.logout_objs: if not hasattr(obj, 'player_logout'): continue try: obj.player_logout(self.data.id) except Exception: log.log_except()
def _uninit(obj): try: if hasattr(obj, 'uninit'): obj.uninit() else: obj.player = None obj._player = None except: log.log_except()
def stop(self): if self.stoped: return self.stoped = True try: self.report.stop() except: log.log_except() self.report = None
def _loop(self): """定时同步数据到GRankMgr""" stime = 60 while True: sleep(stime) try: self.sendToGlobal() except: log.log_except()
def sync_exec(self, func, args, _pickle=True): """ 由该进程执行func, func内独立使用各自的lock,保证同步执行 """ try: if args: return func(*args) return func() except: log.log_except() raise
def _myfunc(): try: rs = func(*args, **kw) params[0] = rs except Exception: log.log_except() params[0] = 0 finally: params[1] = 0
def exec_players_func(self, pids, func, _pickle=True): """ 在玩家所在的逻辑进程执行方法,用于一般的玩家操作 """ rs = {} for pid, p in self.iter_players(pids): try: rs[pid] = func(p) except Exception: log.log_except() return rs
def _loop(self): """ 管理游戏逻辑进程,维持合理的进程数量 """ while not self.stoped: try: self._check_apps() self.logic_mgr.check() except: log.log_except() sleep(10)
def player_mails(self, pids, mids): """ 玩家接受邮件 """ for pid, p in self.iter_players(pids): mid = mids.get(pid) if not mid: continue try: p.mail.recv_mails(mid) except: log.log_except()
def _func(self, *args, **kw): self.__enter__() try: return func(self, *args, **kw) except ConnectionFailure as e: raise ConnectionError(str(e)) except Exception as e: log.log_except('args(%s) kw(%s)', args, kw) finally: self.__exit__()
def _stop(self): if self.stoped: return self.stoped = True log.info('subgame app(%s) stoped:%s', self.name, self.names.keys()) for obj in self.names.values(): if hasattr(obj, 'stop'): try: obj.stop() except: log.log_except('stop(%s) error', obj)
def _loop(self): import app game = Game.instance while not app.stoped: sleep(self.BROADCAST_TIMES) if game and not game.stoped: self.all_ids = set(game.player_mgr.players.keys()) try: self.broadcast() except: log.log_except()
def _call_func(self, func, msg): rs = None self._before_call() try: rs = func(msg) if rs is not None: self.send(rs) except StandardError: log.log_except('func(%s), rs(%s)', func, rs) finally: self._after_call()
def _notice_data(self, l_sec): """ 广播数据 包括世界boss剩余血量和排名 """ #log.debug('(%s)WorldBoss_notice_data %s', self.data.blid, l_sec) hp_resp_f = 'bossHp' rank_resp_f = 'bossRank' hp_time = self.fetch_hp_time c = self.fetch_rank_time / hp_time sleep(l_sec) tmp = 0 self.is_start = is_win =True while not self.gm_stoped: sleep(hp_time) msg = pack_msg(hp_resp_f, 1, data={'hp':self.boss_hp, 'mhp':self.max_hp}) Game.rpc_player_mgr.player_send_msg(self.enter_pids, msg) #log.debug('world hp enter_pids %s %s', self.boss_hp, self.enter_pids) if self.boss_hp <= 0: break if self.boss_start + self.fetch_world_boss_times < time.time(): is_win = False break tmp += 1 if tmp != c: continue tmp = 0 rs, data = self._get_rank() #log.debug('world_rank %s', data) if not rs: continue msg = pack_msg(rank_resp_f, 1, data=data) Game.rpc_player_mgr.player_send_msg(self.enter_pids, msg) self.boss_mgr.w_start_boss = None log.debug('is_win------- %s, gm %s, join-player %s', is_win, self.gm_stoped, len(self.pid_hurts)) if self.gm_stoped: is_win = False #if is_win: #更改为不管怪物是否死都发奖励 try: #发放奖励 self._reward() #vip不参加也发奖励 self._reward_vip() except: log.log_except() #写入log 记录伤害 self._log_info() #清楚数据 self._clear_data() #记录数据 self.save_data(is_win) if self.boss_mgr.gm_wboss: self.boss_mgr.gm_wboss = False self.boss_mgr.gm_start = False self.gm_stoped = False
def _set_data(func, args, kw): self.set_count += 1 self.set_step_count += 1 while 1: try: return func(*args, **kw) except ConnectionError as e: #链接错误,尝试重新保存,保证数据安全 log.error('_process_set error:%s, will retry:%s', e, (func, args, kw)) except: log.log_except('_process_set:%s', (func, args, kw)) break sleep(0.1)
def stop(self): if self.stoped: return self.stoped = True log.warn(u'管理进程开始退出') try: self.sub_mgr.stop() self.rpc_svr.stop() self.web_svr.stop() except: log.log_except() finally: self._waiter.set()
def init_cls_infos(self, cls_infos): if self.cls_infos == cls_infos: return True if self.cls_infos is not None: return False self.cls_infos = cls_infos with self: for k, info in self.cls_infos.iteritems(): try: init_indexs(self, info) except: log.log_except('info:%s', info) raise return True
def _loop(self): """ 定时保存等处理 """ stime = 30 while 1: sleep(stime) try: for pid in self.players.keys(): p = self.players.get(pid) if p is None or not p.logined: continue #是否需要定时保存 if p.save_time + self._SAVE_TIME_ <= time.time(): p.save() except: log.log_except()
def POST(self): data = web.input() data.ip = web.ctx.ip log.info('[idsc]callback:%s', data) act_cls = ACTS[CB_ACT_PAY] try: code, desc = act_cls.GET(sdk, data) except: log.log_except() return json.dumps({'success':0, 'desc':'sys error'}) log.info('[idsc]callbacked:%s', (code, desc)) if code == CODE_SUCC: return json.dumps({'success':1, 'desc':desc}) else: return json.dumps({'success':0, 'desc':desc})
def load(self, app=None): if self._loop_task is None: self._loop_task = spawn(self._loop) for tname, load_func in self.tables.iteritems(): try: load_func() except error: #网络错误 log.log_except() return 0 except: log.log_except() if app and app.stoped: return 0 self.db_ver = self._get_db_ver() return 1
def _call_func(self, func, tag, m): status, msg, err = m.get('s', 1), m.get('d'), m.get('m') rs = None self._before_call() try: rs = func(**msg) if msg else func() if rs is not None: if isinstance(rs, dict) and '_tag' in rs: #hack无奈做法,给pack_msg用 rs['_tag'] = tag self.send(rs) except StandardError: log.log_except('func(%s)(%s), rs(%s)', func, msg, rs) finally: self._after_call()
def _loop(self): """ 定时检查购买支付情况 """ log.info('vip_pay_back start') querys = dict(sid=self.sid, dt=0, status=1, torder={FOP_NE:''}) while 1: sleep(5) try: pays = self.pay_store.query_loads(Pay.TABLE_NAME, querys) for pay in pays: try: self._pay_back(pay) except: log.log_except() except: log.log_except()