You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:45:39 UTC

[buildstream] 06/06: _artifactcache/ostreecache.py: Handle ^C and shutdown child task when initializing cache

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch tristan/multiple-caches
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 0bd2e3b1fa0df81e0f9b00eaee08a877b4499847
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Thu Jan 11 01:30:59 2018 +0900

    _artifactcache/ostreecache.py: Handle ^C and shutdown child task when initializing cache
    
    This fixes issue #141
---
 buildstream/_artifactcache/ostreecache.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index 9987746..c5178a6 100644
--- a/buildstream/_artifactcache/ostreecache.py
+++ b/buildstream/_artifactcache/ostreecache.py
@@ -20,10 +20,11 @@
 
 import multiprocessing
 import os
+import signal
 import string
 import tempfile
 
-from .. import _ostree, utils
+from .. import _ostree, _signals, utils
 from .._exceptions import ArtifactError
 from ..element import _KeyStrength
 from .._ostree import OSTreeError
@@ -411,9 +412,18 @@ class OSTreeCache(ArtifactCache):
         q = multiprocessing.Queue()
         for url in self.urls:
             p = multiprocessing.Process(target=child_action, args=(url, q))
-            p.start()
-            exception, push_url, pull_url, remote_refs = q.get()
-            p.join()
+
+            try:
+
+                # Keep SIGINT blocked in the child process
+                with _signals.blocked([signal.SIGINT], ignore=False):
+                    p.start()
+
+                exception, push_url, pull_url, remote_refs = q.get()
+                p.join()
+            except KeyboardInterrupt:
+                utils._kill_process_tree(p.pid)
+                raise
 
             if exception and on_failure:
                 on_failure(url, exception)