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

Better graceful shutdown for KeyboardInterrupt #19976

Merged
merged 16 commits into from
Jun 16, 2024
Prev Previous commit
Next Next commit
update
  • Loading branch information
awaelchli committed Jun 14, 2024
commit 8e99d147d6311c73bf30f72ccbc9ea36b9f6bd6c
3 changes: 2 additions & 1 deletion src/lightning/pytorch/trainer/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ def _call_and_handle_interrupt(trainer: "pl.Trainer", trainer_fn: Callable, *arg
rank_zero_warn("Detected KeyboardInterrupt, attempting graceful shutdown...")
# user could press Ctrl+C many times, disable KeyboardInterrupt for shutdown
signal.signal(signal.SIGINT, signal.SIG_IGN)
_interrupt(trainer, exception)
launcher = trainer.strategy.launcher
if isinstance(launcher, _SubprocessScriptLauncher):
launcher.kill(signal.SIGKILL)
exit(0)
exit(1)
except BaseException as exception:
_interrupt(trainer, exception)
trainer._teardown()
Expand Down
Loading