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 atexit not working on SIGTERM #1882

Merged
merged 3 commits into from
Jan 30, 2019
Merged

Conversation

blurHY
Copy link
Contributor

@blurHY blurHY commented Jan 29, 2019

I am working on HorizonManager that manages the process of HorizonSpider and zeronet.
It would terminate zeronet by sending SIGTERM.
However, atexit won't work on SIGTERM.We have to manually call sys.exit to trigger atexit.

@HelloZeroNet
Copy link
Owner

Looking great, but please remove the unnecessary import of atexit and use import signal signal.signal(signal.SIGTERM, lambda signum, stack_frame: sys.exit(0)) to reduce global namespace variables

@HelloZeroNet HelloZeroNet merged commit dd46a64 into HelloZeroNet:master Jan 30, 2019
@radfish
Copy link
Contributor

radfish commented Feb 20, 2019

Zeronet 0.6.5 just hangs on receiving SIGTERM from systemd.
Maybe sys.exit(0) from signal handler is not good? Perhaps something needs to be stopped from the main loop? I'll look into it if I find the time.

@blurHY
Copy link
Contributor Author

blurHY commented Feb 20, 2019

sys.exit would only raise a SystemExit exception. Non-daemon threads won't exit

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.

None yet

3 participants