Skip to content

Commit

Permalink
ignore callback removal is process already closed
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Feb 1, 2021
1 parent bfa4011 commit 4d5f1a5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plumpy/base/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ def add_state_event_callback(self, hook: Hashable, callback: EVENT_CALLBACK_TYPE
self._event_callbacks.setdefault(hook, []).append(callback)

def remove_state_event_callback(self, hook: Hashable, callback: EVENT_CALLBACK_TYPE) -> None:
if getattr(self, '_closed', False):
# if the process is closed, then all callbacks have already been removed
return None
try:
self._event_callbacks[hook].remove(callback)
except (KeyError, ValueError):
Expand Down

0 comments on commit 4d5f1a5

Please sign in to comment.