diff --git a/redis/_parsers/base.py b/redis/_parsers/base.py index d5e4add661..77ae0bca7d 100644 --- a/redis/_parsers/base.py +++ b/redis/_parsers/base.py @@ -1,3 +1,4 @@ +import logging import sys from abc import ABC from asyncio import IncompleteReadError, StreamReader, TimeoutError @@ -56,6 +57,8 @@ "Client sent AUTH, but no password is set": AuthenticationError, } +logger = logging.getLogger(__name__) + class BaseParser(ABC): EXCEPTION_CLASSES = { @@ -199,28 +202,41 @@ def handle_push_response(self, response, **kwargs): *_MOVING_MESSAGE, ): return self.pubsub_push_handler_func(response) - if msg_type in _INVALIDATION_MESSAGE and self.invalidation_push_handler_func: - return self.invalidation_push_handler_func(response) - if msg_type in _MOVING_MESSAGE and self.node_moving_push_handler_func: - host, port = response[2].decode().split(":") - ttl = response[1] - id = 1 # Hardcoded value until the notification starts including the id - notification = NodeMovingEvent(id, host, port, ttl) - return self.node_moving_push_handler_func(notification) - if msg_type in _MAINTENANCE_MESSAGES and self.maintenance_push_handler_func: - if msg_type in _MIGRATING_MESSAGE: - ttl = response[1] - id = 2 # Hardcoded value until the notification starts including the id - notification = NodeMigratingEvent(id, ttl) - elif msg_type in _MIGRATED_MESSAGE: - id = 3 # Hardcoded value until the notification starts including the id - notification = NodeMigratedEvent(id) - else: + + try: + if ( + msg_type in _INVALIDATION_MESSAGE + and self.invalidation_push_handler_func + ): + return self.invalidation_push_handler_func(response) + if msg_type in _MOVING_MESSAGE and self.node_moving_push_handler_func: + # Expected message format is: MOVING