Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/1680#discussion_r15628262
--- Diff: python/pyspark/daemon.py ---
@@ -176,13 +120,30 @@ def handle_sigchld(*args):
try:
while not should_exit():
try:
- # Spark tells us to exit by closing stdin
- if os.read(0, 512) == '':
- shutdown()
- except EnvironmentError as err:
- if err.errno != EINTR:
- shutdown()
+ ready_fds = select.select([0, listen_sock], [], [])[0]
+ except select.error as ex:
+ if ex[0] == 4:
+ continue
+ else:
raise
+ if 0 in ready_fds:
+ # Spark told us to exit by closing stdin
+ shutdown()
+ if listen_sock in ready_fds:
+ sock, addr = listen_sock.accept()
+ # Launch a worker process
+ if os.fork() == 0:
+ listen_sock.close()
+ try:
+ worker(sock)
+ except:
+ traceback.print_exc()
+ os._exit(1)
+ else:
+ assert should_exit()
--- End diff --
Why need this? It should exit after task finish, should_exit() will False,
then it will set exit_flag to True, all process will die.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---