From c7ace41f6711e873a4e3ad1daedd73ac6fb89618 Mon Sep 17 00:00:00 2001 From: Kyle Weaver Date: Tue, 2 Jul 2019 17:23:34 -0700 Subject: [PATCH] [BEAM-7670] portable py: prevent race opening worker subprocess --- .../apache_beam/runners/portability/portable_runner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdks/python/apache_beam/runners/portability/portable_runner.py b/sdks/python/apache_beam/runners/portability/portable_runner.py index 117477af93c68..b35b8d518d4e9 100644 --- a/sdks/python/apache_beam/runners/portability/portable_runner.py +++ b/sdks/python/apache_beam/runners/portability/portable_runner.py @@ -495,7 +495,10 @@ def NotifyRunnerAvailable(self, start_worker_request, context): self._worker_threads, start_worker_request.worker_id)] logging.warn("Starting worker with command %s" % (command)) - worker_process = subprocess.Popen(command, stdout=subprocess.PIPE) + worker_process = subprocess.Popen( + command, + stdout=subprocess.PIPE, + close_fds=True) # Register to kill the subprocess on exit. atexit.register(worker_process.kill)