Skip to content

Commit

Permalink
debug logger when state change
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jan 18, 2025
1 parent d524e63 commit c3f0995
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/plumpy/base/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ def transition_to(self, new_state: State | None, **kwargs: Any) -> None:
The arguments are passed to the state class to create state instance.
(process arg does not need to pass since it will always call with 'self' as process)
"""
print(f'try: {self._state} -> {new_state}')
assert not self._transitioning, 'Cannot call transition_to when already transitioning state'

if new_state is None:
Expand Down
4 changes: 2 additions & 2 deletions src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def on_entered(self, from_state: Optional[state_machine.State]) -> None:
elif state_label == process_states.ProcessState.KILLED:
call_with_super_check(self.on_killed)

if self._coordinator and isinstance(self.state, enum.Enum):
if self._coordinator and isinstance(self.state_label, enum.Enum):
from_label = cast(enum.Enum, from_state.LABEL).value if from_state is not None else None
subject = f'state_changed.{from_label}.{self.state_label.value}'
self.logger.info('Process<%s>: Broadcasting state change: %s', self.pid, subject)
Expand Down Expand Up @@ -1342,7 +1342,6 @@ async def step(self) -> None:
self._stepping = True
next_state = None
try:
# XXX: debug log when need to step to next state
next_state = await self._run_task(self._state.execute)
except process_states.Interruption as exception:
# If the interruption was caused by a call to a Process method then there should
Expand All @@ -1368,6 +1367,7 @@ async def step(self) -> None:
self._interrupt_action.run(next_state)
else:
# Everything nominal so transition to the next state
self.logger.debug(f'Process<{self.pid}>: transfer from {self._state.LABEL} to {next_state.LABEL}')
self.transition_to(next_state)

finally:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def test_kill(self):
proc.kill(msg_text=msg_text)
self.assertTrue(proc.killed())
self.assertEqual(proc.killed_msg()[MESSAGE_TEXT_KEY], msg_text)
self.assertEqual(proc.state, ProcessState.KILLED)
self.assertEqual(proc.state_label, ProcessState.KILLED)

def test_wait_continue(self):
proc = utils.WaitForSignalProcess()
Expand Down

0 comments on commit c3f0995

Please sign in to comment.