fix: redis 订阅 bug

pull/7579/head
xinwen 3 years ago committed by Jiangjie.Bai
parent 55fae1667d
commit f994f5d776

@ -79,7 +79,7 @@ def subscribe_node_assets_mapping_expire(sender, **kwargs):
Node.expire_node_all_asset_ids_mapping_from_memory(root_org_id) Node.expire_node_all_asset_ids_mapping_from_memory(root_org_id)
def keep_subscribe_node_assets_relation(): def keep_subscribe_node_assets_relation():
node_assets_mapping_for_memory_pub_sub.keep_handle_msg(handle_node_relation_change) node_assets_mapping_for_memory_pub_sub.subscribe(handle_node_relation_change)
t = threading.Thread(target=keep_subscribe_node_assets_relation) t = threading.Thread(target=keep_subscribe_node_assets_relation)
t.daemon = True t.daemon = True

@ -90,6 +90,7 @@ class RedisPubSub:
def subscribe(self, _next, error=None, complete=None): def subscribe(self, _next, error=None, complete=None):
ps = self.redis.pubsub() ps = self.redis.pubsub()
ps.subscribe(self.ch)
sub = Subscription(self.ch, ps) sub = Subscription(self.ch, ps)
sub.keep_handle_msg(_next, error, complete) sub.keep_handle_msg(_next, error, complete)
return sub return sub

@ -46,7 +46,7 @@ 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_org_mapping(): def keep_subscribe_org_mapping():
orgs_mapping_for_memory_pub_sub.keep_handle_msg( orgs_mapping_for_memory_pub_sub.subscribe(
lambda org_id: Organization.expire_orgs_mapping() lambda org_id: Organization.expire_orgs_mapping()
) )

@ -80,9 +80,7 @@ def subscribe_settings_change(sender, **kwargs):
logger.debug("Start subscribe setting change") logger.debug("Start subscribe setting change")
def keep_subscribe_settings_change(): def keep_subscribe_settings_change():
setting_pub_sub.keep_handle_msg( setting_pub_sub.subscribe(lambda name: Setting.refresh_item(name))
lambda name: Setting.refresh_item(name)
)
t = threading.Thread(target=keep_subscribe_settings_change) t = threading.Thread(target=keep_subscribe_settings_change)
t.daemon = True t.daemon = True

Loading…
Cancel
Save