Skip to content

Commit

Permalink
Fix leftover /tmp/manhole-pid sockets in the tests
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nirs committed Sep 6, 2014
1 parent e2ff0b1 commit 8ac2c1f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_manhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
SOCKET_PATH = '/tmp/manhole-socket'


def handle_sigterm(signo, frame):
# Simulate real termination
print("Terminated")
sys.exit(128 + signo)


# Handling sigterm ensure that atexit functions are called, and we do not leave
# leftover /tmp/manhole-pid sockets.
signal.signal(signal.SIGTERM, handle_sigterm)


def is_module_available(mod):
try:
return imp.find_module(mod)
Expand Down

0 comments on commit 8ac2c1f

Please sign in to comment.