提交 a2e39799 编写于 作者: X xinwen 提交者: baltery

fix: org_mapping 保护订阅线程

上级 f11d3c1c
...@@ -46,12 +46,19 @@ def subscribe_orgs_mapping_expire(sender, **kwargs): ...@@ -46,12 +46,19 @@ def subscribe_orgs_mapping_expire(sender, **kwargs):
logger.debug("Start subscribe for expire orgs mapping from memory") logger.debug("Start subscribe for expire orgs mapping from memory")
def keep_subscribe(): def keep_subscribe():
subscribe = orgs_mapping_for_memory_pub_sub.subscribe() while True:
for message in subscribe.listen(): try:
if message['type'] != 'message': subscribe = orgs_mapping_for_memory_pub_sub.subscribe()
continue for message in subscribe.listen():
Organization.expire_orgs_mapping() if message['type'] != 'message':
logger.debug('Expire orgs mapping') continue
if message['data'] == b'error':
raise ValueError
Organization.expire_orgs_mapping()
logger.debug('Expire orgs mapping')
except Exception as e:
logger.exception(f'subscribe_orgs_mapping_expire: {e}')
Organization.expire_orgs_mapping()
t = threading.Thread(target=keep_subscribe) t = threading.Thread(target=keep_subscribe)
t.daemon = True t.daemon = True
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册