Skip to content

Commit 282c2c4

Browse files
committed
Remove daemon.py exit logging, since it caused problems:
After including these logging statements, orphaned workers might stay alive after the driver died. My current theory is that the print to sys.stderr failed due to Java closing the file and an exception was thrown that managed to propagate to to the uncaught exception handler, causing daemon.py to exit before it could send SIGHUP to its children.
1 parent 8554536 commit 282c2c4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

python/pyspark/daemon.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def worker(sock):
4747

4848
signal.signal(SIGHUP, SIG_DFL)
4949
signal.signal(SIGCHLD, SIG_DFL)
50+
signal.signal(SIGTERM, SIG_DFL)
5051

5152
# Blocks until the socket is closed by draining the input stream
5253
# until it raises an exception or returns EOF.
@@ -93,10 +94,9 @@ def shutdown(code):
9394
os.kill(0, SIGHUP)
9495
exit(code)
9596

96-
def sig_term(signum, frame):
97-
print >> sys.stderr, "daemon.py shutting down due to SIGTERM"
97+
def handle_sigterm(*args):
9898
shutdown(1)
99-
signal.signal(SIGTERM, sig_term) # Gracefully exit on SIGTERM
99+
signal.signal(SIGTERM, handle_sigterm) # Gracefully exit on SIGTERM
100100
signal.signal(SIGHUP, SIG_IGN) # Don't die on SIGHUP
101101

102102
# Cleanup zombie children
@@ -124,7 +124,6 @@ def handle_sigchld(*args):
124124
raise
125125
if 0 in ready_fds:
126126
# Spark told us to exit by closing stdin
127-
print >> sys.stderr, "daemon.py shutting down because Java closed stdin"
128127
shutdown(0)
129128
if listen_sock in ready_fds:
130129
sock, addr = listen_sock.accept()
@@ -141,7 +140,6 @@ def handle_sigchld(*args):
141140
else:
142141
sock.close()
143142
finally:
144-
print >> sys.stderr, "daemon.py shutting down due to uncaught exception"
145143
shutdown(1)
146144

147145

0 commit comments

Comments
 (0)