-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Python graceful exit upon interrupt signal #39
Comments
ok this seems cool! just to know: # listen for interrupt signal and issue stopEmptyMinecraftServer(true) before exiting
atexit.register(stopEmptyMinecraftServer, forceExec=True) because for me it seemed to do the job.. |
Well, pressing
As such I tried to intercept the KeybordInterrupt with the signal listener and since a simple |
Will test if mc server gets shutdown on Windows when closing console and in Linux after two times |
facepalm os.Exit(0) needs to be written in Uppercase... |
Wait... the uppercase thing is used in golang and I think it'correct to write |
... Oops.
Well, no. It's not exactly nice interrupt handling, but this is also not a bug, as the server is correctly shutting down upon exit. On Windows |
a okok fiuuu so now i'm in peace with myself. so i think I can move on. |
Currently the Python script throws exceptions when interrupted through a SIGINT (ctrl + c) or SIGTERM.
To gracefully exit the script a signal handler needs to be introduced. This could look something like this:
Though after trying around a bit, the script continues to run even after successfully going through the join loop on my PC.
It also spawns a new Timer thread, which at least shows that the original Timer thread was successfully cancelled.
I think that either there is a thread that is not listed with
enumerate()
orsys.exit(0)
is not working correctly, but I don't have enough experience with python threading to figure out what's really going on.Resources:
Signal library
Threading library
The text was updated successfully, but these errors were encountered: