|
38 | 38 | except ModuleNotFoundError: |
39 | 39 | from contextvars import ContextVar |
40 | 40 |
|
41 | | -import kiwipy |
42 | 41 | import yaml |
43 | 42 |
|
44 | 43 | from . import events, exceptions, message, persistence, ports, process_states, utils |
45 | | -from .futures import capture_exceptions, CancellableAction |
46 | 44 | from .base import state_machine |
47 | 45 | from .base.state_machine import StateEntryFailed, StateMachine, TransitionFailed, event |
48 | 46 | from .base.utils import call_with_super_check, super_check |
49 | 47 | from .event_helper import EventHelper |
| 48 | +from .futures import CancellableAction, capture_exceptions |
50 | 49 | from .process_listener import ProcessListener |
51 | 50 | from .process_spec import ProcessSpec |
52 | 51 | from .utils import PID_TYPE, SAVED_STATE_TYPE, protected |
@@ -313,9 +312,9 @@ def init(self) -> None: |
313 | 312 |
|
314 | 313 | try: |
315 | 314 | # filter out state change broadcasts |
316 | | - # TODO: pattern filter should be moved to add_broadcast_subscriber. |
317 | | - subscriber = kiwipy.BroadcastFilter(self.broadcast_receive, subject=re.compile(r'^(?!state_changed).*')) |
318 | | - identifier = self._communicator.add_broadcast_subscriber(subscriber, identifier=str(self.pid)) |
| 315 | + identifier = self._communicator.add_broadcast_subscriber( |
| 316 | + self.broadcast_receive, subject_filter=re.compile(r'^(?!state_changed).*'), identifier=str(self.pid) |
| 317 | + ) |
319 | 318 | self.add_cleanup(functools.partial(self._communicator.remove_broadcast_subscriber, identifier)) |
320 | 319 | except concurrent.futures.TimeoutError: |
321 | 320 | self.logger.exception('Process<%s>: failed to register as a broadcast subscriber', self.pid) |
@@ -715,6 +714,7 @@ def on_entered(self, from_state: Optional[process_states.State]) -> None: |
715 | 714 | call_with_super_check(self.on_killed) |
716 | 715 |
|
717 | 716 | if self._communicator and isinstance(self.state, enum.Enum): |
| 717 | + # FIXME: move all to `coordinator.broadcast()` call and in rmq implement coordinator |
718 | 718 | from plumpy.rmq.exceptions import CommunicatorChannelInvalidStateError, CommunicatorConnectionClosed |
719 | 719 |
|
720 | 720 | from_label = cast(enum.Enum, from_state.LABEL).value if from_state is not None else None |
|
0 commit comments