phoerious commented on a change in pull request #16658:
URL: https://github.com/apache/beam/pull/16658#discussion_r813250990
##########
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:
Because wait blocks. The loop is supposed to exit if the process exits
or after 5 seconds. The latter won't happen with `wait()`. But as mentioned
above, we can replace the whole function with a `SIGTERM` and a `wait()` if
it's guaranteed that only the `boot` Go binary will be used here (or any other
binary that is guaranteed to never ignore `SIGTERM`).
--
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]