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

Removed lock file upon receiving interrupt signals #72

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

SandakovMM
Copy link
Contributor

No description provided.

@SandakovMM SandakovMM self-assigned this Sep 9, 2024
@@ -581,6 +593,10 @@ def main():
printerr(f"{util_name} is ongoing. To check its status, please use `--monitor` or `--status`")
return 1

exit_signal_handler = create_free_lock_exit_signal_handler(lock_file)
for signum in (signal.SIGINT, signal.SIGTERM, signal.SIGHUP, signal.SIGABRT, signal.SIGSEGV):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signal documentation states that it makes little sense to catch SIGSEGV.

def signal_handler(signum, frame):
log.info(f"Received signal {signum}, going to free lockfile {lock_file!r}...")
try:
os.unlink(lock_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it could cause double unlink with try_lock(), producing spurious warning in log, because sys.exit() will just raise SystemExit somewhere on the main thread, so try_lock() exit procedure will be executed too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually simplifies things a lot, thx

Copy link
Contributor

@kpushkaryov kpushkaryov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase before merge.

@SandakovMM SandakovMM merged commit cd4724a into main Sep 11, 2024
3 checks passed
@SandakovMM SandakovMM deleted the free-lock-on-signals branch September 11, 2024 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants