From 516b8af22ba60cdbdaf9cb9e5a174ad5892fbca7 Mon Sep 17 00:00:00 2001 From: Neelam Kushwah Date: Mon, 26 Aug 2024 11:19:22 -0400 Subject: [PATCH] Fix bug in unregister_listener method (#17) --- up_transport_zenoh/uptransportzenoh.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/up_transport_zenoh/uptransportzenoh.py b/up_transport_zenoh/uptransportzenoh.py index 974c2c2..344cd51 100644 --- a/up_transport_zenoh/uptransportzenoh.py +++ b/up_transport_zenoh/uptransportzenoh.py @@ -340,17 +340,17 @@ async def unregister_listener( # Publish & Notification if flag & (MessageFlag.PUBLISH | MessageFlag.NOTIFICATION): # Get Zenoh key - zenoh_key = ZenohUtils.to_zenoh_key_string(source_filter, sink_filter) + zenoh_key = ZenohUtils.to_zenoh_key_string(self.authority_name, source_filter, sink_filter) return self._remove_publish_listener(zenoh_key, listener) # RPC request if flag & MessageFlag.REQUEST: # Get Zenoh key - zenoh_key = ZenohUtils.to_zenoh_key_string(source_filter, sink_filter) + zenoh_key = ZenohUtils.to_zenoh_key_string(self.authority_name, source_filter, sink_filter) return self._remove_request_listener(zenoh_key, listener) # RPC response if flag & MessageFlag.RESPONSE: if sink_filter is not None: # Get Zenoh key - zenoh_key = ZenohUtils.to_zenoh_key_string(sink_filter, source_filter) + zenoh_key = ZenohUtils.to_zenoh_key_string(self.authority_name, sink_filter, source_filter) return self._remove_response_listener(zenoh_key) else: return UStatus(code=UCode.INVALID_ARGUMENT, message="Sink should not be None in Response") @@ -358,7 +358,7 @@ async def unregister_listener( def _remove_response_listener(self, zenoh_key: str) -> UStatus: with self.rpc_callback_lock: if self.rpc_callback_map.pop(zenoh_key, None) is None: - msg = "RPC response callback doesn't exist" + msg = f"RPC response callback doesn't exist for : {zenoh_key}" logging.error(msg) return UStatus(code=UCode.NOT_FOUND, message=msg) return UStatus(code=UCode.OK) @@ -366,7 +366,7 @@ def _remove_response_listener(self, zenoh_key: str) -> UStatus: def _remove_publish_listener(self, zenoh_key: str, listener: UListener) -> UStatus: with self.subscriber_lock: if self.subscriber_map.pop((zenoh_key, listener), None) is None: - msg = "Listener not registered for filters: {source_filter}, {sink_filter}" + msg = f"Listener not registered for : {zenoh_key}" logging.error(msg) return UStatus(code=UCode.NOT_FOUND, message=msg) @@ -375,7 +375,7 @@ def _remove_publish_listener(self, zenoh_key: str, listener: UListener) -> UStat def _remove_request_listener(self, zenoh_key: str, listener: UListener) -> UStatus: with self.queryable_lock: if self.queryable_map.pop((zenoh_key, listener), None) is None: - msg = "RPC request listener doesn't exist" + msg = f"RPC request listener doesn't exist for : {zenoh_key}" logging.error(msg) return UStatus(code=UCode.NOT_FOUND, message=msg) return UStatus(code=UCode.OK, message="Listener removed successfully")