This is an automated email from the ASF dual-hosted git repository. not-in-ldap pushed a commit to branch aevri/win32_minimal_seemstowork_20190829 in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 0fa65b0bf18c86dd0b61576b6ddab09836a62a9d Author: Angelos Evripiotis <[email protected]> AuthorDate: Tue Apr 2 13:27:37 2019 +0100 WIP: win32: job: signals / win32 --- src/buildstream/_scheduler/jobs/job.py | 12 ++++++------ src/buildstream/_scheduler/scheduler.py | 4 +++- src/buildstream/_signals.py | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py index 480a76c..9864e4a 100644 --- a/src/buildstream/_scheduler/jobs/job.py +++ b/src/buildstream/_scheduler/jobs/job.py @@ -211,7 +211,7 @@ class Job(): # the child process does not inherit the parent's state, but the main # process will be notified of any signal after we launch the child. # - with _signals.blocked([signal.SIGINT, signal.SIGTSTP, signal.SIGTERM], ignore=False): + with _signals.blocked([signal.SIGINT, signal.SIGTERM], ignore=False): self._process.start() # Wait for the child task to complete. @@ -692,15 +692,15 @@ class ChildJob(): # This avoids some SIGTSTP signals from grandchildren # getting propagated up to the master process - os.setsid() + #os.setsid() # First set back to the default signal handlers for the signals # we handle, and then clear their blocked state. # - signal_list = [signal.SIGTSTP, signal.SIGTERM] - for sig in signal_list: - signal.signal(sig, signal.SIG_DFL) - signal.pthread_sigmask(signal.SIG_UNBLOCK, signal_list) + #signal_list = [signal.SIGTSTP, signal.SIGTERM] + #for sig in signal_list: + # signal.signal(sig, signal.SIG_DFL) + #signal.pthread_sigmask(signal.SIG_UNBLOCK, signal_list) # Assign the queue we passed across the process boundaries # diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index ae20fcd..7f876b5 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -202,7 +202,7 @@ class Scheduler(): # Block this until we're finished terminating jobs, # this will remain blocked forever. - signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGINT]) + #signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGINT]) # jobs_suspended() # @@ -575,11 +575,13 @@ class Scheduler(): # Connects our signal handler event callbacks to the mainloop # def _connect_signals(self): + return self.loop.add_signal_handler(signal.SIGINT, self._interrupt_event) self.loop.add_signal_handler(signal.SIGTERM, self._terminate_event) self.loop.add_signal_handler(signal.SIGTSTP, self._suspend_event) def _disconnect_signals(self): + return self.loop.remove_signal_handler(signal.SIGINT) self.loop.remove_signal_handler(signal.SIGTSTP) self.loop.remove_signal_handler(signal.SIGTERM) diff --git a/src/buildstream/_signals.py b/src/buildstream/_signals.py index 2df2c79..733f28e 100644 --- a/src/buildstream/_signals.py +++ b/src/buildstream/_signals.py @@ -135,6 +135,8 @@ def suspend_handler(sig, frame): # @contextmanager def suspendable(suspend_callback, resume_callback): + yield + return global suspendable_stack # pylint: disable=global-statement outermost = bool(not suspendable_stack) @@ -164,6 +166,8 @@ def suspendable(suspend_callback, resume_callback): # @contextmanager def blocked(signal_list, ignore=True): + yield + return with ExitStack() as stack:
