fix: subscribe_settings_change

pull/5940/head
xinwen 2021-04-12 11:30:09 +08:00 committed by 老广
parent 682f6b2fb9
commit 6616374c30
1 changed files with 13 additions and 7 deletions

View File

@ -71,6 +71,8 @@ def subscribe_settings_change(sender, **kwargs):
logger.debug("Start subscribe setting change") logger.debug("Start subscribe setting change")
def keep_subscribe(): def keep_subscribe():
while True:
try:
sub = setting_pub_sub.subscribe() sub = setting_pub_sub.subscribe()
for msg in sub.listen(): for msg in sub.listen():
if msg["type"] != "message": if msg["type"] != "message":
@ -78,6 +80,10 @@ def subscribe_settings_change(sender, **kwargs):
item = msg['data'].decode() item = msg['data'].decode()
logger.debug("Found setting change: {}".format(str(item))) logger.debug("Found setting change: {}".format(str(item)))
Setting.refresh_item(item) Setting.refresh_item(item)
except Exception as e:
logger.exception(f'subscribe_settings_change: {e}')
Setting.refresh_all_settings()
t = threading.Thread(target=keep_subscribe) t = threading.Thread(target=keep_subscribe)
t.daemon = True t.daemon = True
t.start() t.start()