You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 08:22:48 UTC
[buildstream] 12/25: WIP: win32: job: replace add_child_handler
with thread
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch aevri/win32_minimal
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 23a9d3684baa3c4f3111e46c9655c3242c1cceb1
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Tue Apr 2 13:26:08 2019 +0100
WIP: win32: job: replace add_child_handler with thread
---
src/buildstream/_scheduler/jobs/job.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index 46bb6bf..513af70 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -47,6 +47,21 @@ class _ReturnCode(FastEnum):
SKIPPED = 3
+def _call_on_waitpid_threadfun(running_loop, process, callback):
+ process.join()
+ running_loop.call_soon_threadsafe(callback, process.pid, process.exitcode)
+
+
+def call_on_waitpid(running_loop, pid, callback):
+ import threading
+ t = threading.Thread(
+ target=_call_on_waitpid_threadfun,
+ args=(running_loop, pid, callback)
+ )
+ t.start()
+ return t
+
+
# JobStatus:
#
# The job completion status, passed back through the
@@ -258,8 +273,7 @@ class Job():
# an event loop callback. Otherwise, if the job completes too fast, then
# the callback is called immediately.
#
- self._watcher = asyncio.get_child_watcher()
- self._watcher.add_child_handler(self._process.pid, self._parent_child_completed)
+ self._watcher = call_on_waitpid(self._scheduler.loop, self._process, self._parent_child_completed)
# terminate()
#