This commit is contained in:
aozhiwei 2020-01-10 15:04:01 +08:00
parent 8b29369ca6
commit 24776f8e82
3 changed files with 26 additions and 0 deletions

View File

@ -12,3 +12,23 @@ timer = i_timer()
def isOnlineEnv():
return not os.getenv("SERVER_ENV");
def scanRedisKey(conn, pattern):
result = {}
cursor, keys = conn.scan(0, pattern, 1000)
while cursor != 0 or len(keys) > 0:
for key in keys:
if key in result:
result[key] += result[key]
else:
result[key] = 0
keys = []
if cursor != 0:
cursor, keys = conn.scan(cursor, pattern, 1000)
return result
def getChannelByAccountId(account_id):
tmp_strings = account_id.split('_')
if len(tmp_strings) < 3:
return 0
return tmp_strings[0]

View File

@ -42,6 +42,9 @@ class _App:
def callAt(self, when, callback):
tornado.ioloop.IOLoop.current().call_at(when, callback)
def callLater(self, when, callback):
tornado.ioloop.IOLoop.current().call_later(when, callback)
def registerHandler(self, c, a, callback):
self._requestHandler[c + '$' + a] = callback

View File

@ -18,5 +18,8 @@ class _Timer:
def callAt(self, when, callback):
f7.app.callAt(when, callback)
def callLater(self, when, callback):
f7.app.callLater(when, callback)
def instance():
return _Timer.instance()