This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch aevri/win32_minimal_seemstowork_20190829 in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit da883afc0077da39f451e5f9f32cfe20590d5807 Author: Angelos Evripiotis <[email protected]> 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 cdd403a..480a76c 100644 --- a/src/buildstream/_scheduler/jobs/job.py +++ b/src/buildstream/_scheduler/jobs/job.py @@ -47,6 +47,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 @@ -221,8 +236,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() #
