Skip to content

Commit

Permalink
Catch ChannelInvalidStateError in process state change (#278)
Browse files Browse the repository at this point in the history
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: db2af9a
  • Loading branch information
sphuber committed Nov 13, 2023
1 parent fc66001 commit fda244a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fda244a

Please sign in to comment.