From fda244a139e26472c37f698d7d64f3d6e13ad57b Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Fri, 10 Nov 2023 15:40:02 +0100 Subject: [PATCH] Catch `ChannelInvalidStateError` in process state change (#278) In `Process.on_entered`, the `Communicator.broadcast_send` method is called to broadcast the state change to subscribers over RabbitMQ. This can throw a `ChannelInvalidStateError` in addition to the `ConnectionClose` exception that was already being caught, in case there is a problem with the connection. Cherry-pick: db2af9acf7c139798a21e574d6308ae21b3b7513 --- src/plumpy/processes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plumpy/processes.py b/src/plumpy/processes.py index 57e12af5..c9c1a118 100644 --- a/src/plumpy/processes.py +++ b/src/plumpy/processes.py @@ -34,7 +34,7 @@ except ModuleNotFoundError: from contextvars import ContextVar -from aio_pika.exceptions import ConnectionClosed +from aio_pika.exceptions import ChannelInvalidStateError, ConnectionClosed import kiwipy import yaml @@ -718,7 +718,7 @@ def on_entered(self, from_state: Optional[process_states.State]) -> None: self.logger.info('Process<%s>: Broadcasting state change: %s', self.pid, subject) try: self._communicator.broadcast_send(body=None, sender=self.pid, subject=subject) - except ConnectionClosed: + except (ConnectionClosed, ChannelInvalidStateError): message = 'Process<%s>: no connection available to broadcast state change from %s to %s' self.logger.warning(message, self.pid, from_label, self.state.value) except kiwipy.TimeoutError: