phoerious commented on a change in pull request #16658:
URL: https://github.com/apache/beam/pull/16658#discussion_r813728029
##########
File path: sdks/python/apache_beam/runners/worker/worker_pool_main.py
##########
@@ -51,6 +51,28 @@
_LOGGER = logging.getLogger(__name__)
+def kill_process_gracefully(proc, timeout=10):
+ """
+ Kill a worker process gracefully by sending a SIGTERM and waiting for
+ it to finish. A SIGKILL will be sent if the process has not finished
+ after ``timeout`` seconds.
+ """
+ def _kill():
+ proc.terminate()
+ t = time.time()
+ while time.time() < t + timeout:
+ time.sleep(0.01)
+ if proc.poll() is not None:
Review comment:
I changed it to wait with timeout, but again, we can reduce it even more
if we can guarantee that the child process will not hang indefinitely.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]