Skip to content

Commit

Permalink
Catch ChannelInvalidStateError in process state change
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.
  • Loading branch information
sphuber committed Nov 10, 2023
1 parent 98a375f commit a7b75f1
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):

Check warning on line 721 in src/plumpy/processes.py

View check run for this annotation

Codecov / codecov/patch

src/plumpy/processes.py#L721

Added line #L721 was not covered by tests
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 a7b75f1

Please sign in to comment.