-
Notifications
You must be signed in to change notification settings - Fork 23
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
manhole socket not removed when terminating a process #8
Comments
Adding manhole.uninstall() would be useful for application that want to ensure that the manhole is cleanup properly. manhole.uninstall() should
This of course will not help manhole inherited in a sub process, but it will be good enough for me, since I'm using socket_path. |
manhole.install() registers an exit function removing the manhole socket, but atexit function do not run when process is terminated by an unhandled signal. In the fork tests, we avoid this issue by terminating child processes with SIGINT, however the test child processes, created by the process_tests library, are terminate using SIGTERM in TestProcess.__exit__. Adding SIGTERM signal handler fixed this issue. We probably need to document this as a workaround for issue ionelmc#8
Workaround: define a signal hanlder for SIGTERM:
|
Should this be part of the documentation ? Thanks, On Sat, Sep 6, 2014 at 10:35 PM, Nir Soffer [email protected]
|
I guess it should, maybe under "Known issues". |
I think we can register the signal handler in manhole, checking that no signal handler was installed before that:
If a user install sigterm handler after that, we don't care, since atexit will be called. If the user did not install one, our handler will make sure the socket will be cleaned. The only issue is that installing signals is possible only from the main thread, so manhole.install() will have to be called from the main thread. I don't think this is an issue since anyone will call this from the main thread anyway. |
I think this issue is resolved by #8, so we can close it now. |
Although manhole register the removal function using atexit module, the removal function is not run when sending the process SIGTERM.
To reproduce:
Create a script::
import manhole
import time
manhole.install(socket_path='exit.manhole')
time.sleep(30)
Run the script in the backround
python exit.py &
And terminate it
kill
The removal function is not called, and manhole socket is not removed.
Tested on Fedora 19.
This seems faulty implementation of atexit module.
Workarounds:
The text was updated successfully, but these errors were encountered: