summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-11 01:30:59 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-11 02:25:55 +0900
commit0bd2e3b1fa0df81e0f9b00eaee08a877b4499847 (patch)
tree7db44d9e278410a4c523d8d40075838668dc0a98
parent709973f61e15bc4af05a394074ac6fd130604d1d (diff)
downloadbuildstream-tristan/multiple-caches.tar.gz
_artifactcache/ostreecache.py: Handle ^C and shutdown child task when initializing cachetristan/multiple-caches
This fixes issue #141
-rw-r--r--buildstream/_artifactcache/ostreecache.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index 9987746b0..c5178a646 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)