You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/02/23 19:23:58 UTC

[GitHub] [beam] y1chi commented on a change in pull request #16658: [BEAM-12792] Install pipline dependencies to temporary venv

y1chi commented on a change in pull request #16658:
URL: https://github.com/apache/beam/pull/16658#discussion_r813240633



##########
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:
       why not proc.wait() directly without looping?




-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org