Skip to content

Commit 97eec3f

Browse files
committed
Kill the worker if flush fails in daemon.py
1 parent 5e46f4c commit 97eec3f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/pyspark/daemon.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import traceback
2525
import time
2626
import gc
27+
import faulthandler
2728
from errno import EINTR, EAGAIN
2829
from socket import AF_INET, AF_INET6, SOCK_STREAM, SOMAXCONN
2930
from signal import SIGHUP, SIGTERM, SIGCHLD, SIG_DFL, SIG_IGN, SIGINT
@@ -85,7 +86,12 @@ def worker(sock, authenticated):
8586
try:
8687
outfile.flush()
8788
except Exception:
88-
pass
89+
faulthandler_log_path = os.environ.get("PYTHON_FAULTHANDLER_DIR", None)
90+
if faulthandler_log_path:
91+
faulthandler_log_path = os.path.join(faulthandler_log_path, str(os.getpid()))
92+
with open(faulthandler_log_path, "w") as faulthandler_log_file:
93+
faulthandler.dump_traceback(file=faulthandler_log_file)
94+
raise
8995
return exit_code
9096

9197

0 commit comments

Comments
 (0)