From 1f00b0e3ac9360e5b9f5d3a0855a19528c41d2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20Jer=C5=A1e?= Date: Thu, 13 Jun 2024 10:01:32 +0200 Subject: [PATCH] Make receive method more robust --- resolwe/flow/executors/socket_utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resolwe/flow/executors/socket_utils.py b/resolwe/flow/executors/socket_utils.py index 71dde6582..986489339 100644 --- a/resolwe/flow/executors/socket_utils.py +++ b/resolwe/flow/executors/socket_utils.py @@ -717,13 +717,16 @@ async def start_listening(self): received = await self._receive_message() if received is None: - self.logger.info( - f"Communicator {self.name}: received empty message, closing communicator." - ) - break + if self._terminating.is_set(): + self.logger.info( + f"Communicator {self.name}: received empty message, closing communicator." + ) + break + # Invalid message received, resume listening. + else: + continue identity, message = received - if message.message_type is MessageType.HEARTBEAT: logger.debug("Got heartbeat from peer '%s'.", identity) if self.heartbeat_handler is not None: