Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: release signal handlers after run execution #4682

Merged
merged 3 commits into from
Jan 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions aiida/engine/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,17 @@ def kill_process(_num, _frame):
LOGGER.critical('runner received interrupt, killing process %s', process_inited.pid)
process_inited.kill(msg='Process was killed because the runner received an interrupt')

signal.signal(signal.SIGINT, kill_process)
signal.signal(signal.SIGTERM, kill_process)
original_handler_int = signal.getsignal(signal.SIGINT)
original_handler_term = signal.getsignal(signal.SIGTERM)

try:
signal.signal(signal.SIGINT, kill_process)
signal.signal(signal.SIGTERM, kill_process)
process_inited.execute()
finally:
signal.signal(signal.SIGINT, original_handler_int)
signal.signal(signal.SIGTERM, original_handler_term)

process_inited.execute()
return process_inited.outputs, process_inited.node

def run(self, process: TYPE_RUN_PROCESS, *args: Any, **inputs: Any) -> Dict[str, Any]:
Expand Down