mirror of https://github.com/jumpserver/jumpserver
fix: org_mapping 保护订阅线程
parent
f11d3c1cf2
commit
a2e3979916
|
@ -46,12 +46,19 @@ def subscribe_orgs_mapping_expire(sender, **kwargs):
|
|||
logger.debug("Start subscribe for expire orgs mapping from memory")
|
||||
|
||||
def keep_subscribe():
|
||||
subscribe = orgs_mapping_for_memory_pub_sub.subscribe()
|
||||
for message in subscribe.listen():
|
||||
if message['type'] != 'message':
|
||||
continue
|
||||
Organization.expire_orgs_mapping()
|
||||
logger.debug('Expire orgs mapping')
|
||||
while True:
|
||||
try:
|
||||
subscribe = orgs_mapping_for_memory_pub_sub.subscribe()
|
||||
for message in subscribe.listen():
|
||||
if message['type'] != 'message':
|
||||
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.daemon = True
|
||||
|
|
Loading…
Reference in New Issue