Skip to content

Commit b22e0b5

Browse files
authored
Fix(lock): SIGTERM handling to allow cleanup code execution (#785)
1 parent 3ab4d43 commit b22e0b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

codecarbon/lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _handle_exit(self, signum, frame):
3838
"""Ensures the lock file is removed when the script is interrupted."""
3939
logger.debug(f"Signal {signum} received. Releasing lock and exiting.")
4040
self.release()
41-
os._exit(1) # Exit immediately to prevent further execution
41+
raise SystemExit(1) # Exit gracefully to prevent further execution
4242

4343
def acquire(self):
4444
"""Creates a lock file and ensures it's the only instance running."""

0 commit comments

Comments
 (0)