You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:30:22 UTC
[buildstream] 14/21: WIP: win32: job: replace add_child_handler
with thread
This is an automated email from the ASF dual-hosted git repository.
not-in-ldap pushed a commit to branch aevri/win32
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 61c228d5ead35a9c6318f4e4e9e190d3d8f4365e
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 3b228bc..debc470 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -49,6 +49,21 @@ class _ReturnCode(enum.IntEnum):
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
@@ -299,8 +314,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()
#