Browse Source

fix: redis 订阅 bug

pull/7579/head
xinwen 3 years ago committed by Jiangjie.Bai
parent
commit
f994f5d776
  1. 2
      apps/assets/signals_handler/node_assets_mapping.py
  2. 1
      apps/common/utils/connection.py
  3. 2
      apps/orgs/signals_handler/common.py
  4. 4
      apps/settings/signals_handler.py

2
apps/assets/signals_handler/node_assets_mapping.py

@ -79,7 +79,7 @@ def subscribe_node_assets_mapping_expire(sender, **kwargs):
Node.expire_node_all_asset_ids_mapping_from_memory(root_org_id)
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.daemon = True

1
apps/common/utils/connection.py

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

2
apps/orgs/signals_handler/common.py

@ -46,7 +46,7 @@ def subscribe_orgs_mapping_expire(sender, **kwargs):
logger.debug("Start subscribe for expire orgs mapping from memory")
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()
)

4
apps/settings/signals_handler.py

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

Loading…
Cancel
Save