summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-09-12 11:05:19 +0100
committerBenjamin Schubert <contact@benschubert.me>2019-10-02 13:02:18 +0100
commitba605659c63f69f39a206f12d7c65f92648c915a (patch)
tree4e37e61aeb5eb75c84a378a84635bf284d4076b3
parentdbc8f59f3e480610ca054eca07a823a2d9d5dc58 (diff)
downloadbuildstream-ba605659c63f69f39a206f12d7c65f92648c915a.tar.gz
cascache.py: Extract buildbox-casd termination in its own method
-rw-r--r--src/buildstream/_cas/cascache.py45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 97ee2edd7..a62d04fac 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -183,23 +183,7 @@ class CASCache():
if self._casd_process:
self.close_channel()
- self._casd_process.terminate()
- try:
- # Don't print anything if buildbox-casd terminates quickly
- self._casd_process.wait(timeout=0.5)
- except subprocess.TimeoutExpired:
- if messenger:
- cm = messenger.timed_activity("Terminating buildbox-casd")
- else:
- cm = contextlib.suppress()
- with cm:
- try:
- self._casd_process.wait(timeout=15)
- except subprocess.TimeoutExpired:
- self._casd_process.kill()
- self._casd_process.wait(timeout=15)
- self._casd_process = None
-
+ self._terminate_casd_process(messenger)
shutil.rmtree(self._casd_socket_tempdir)
# contains():
@@ -945,6 +929,33 @@ class CASCache():
# Upload any blobs missing on the server
self.send_blobs(remote, missing_blobs)
+ # _terminate_casd_process()
+ #
+ # Terminate the buildbox casd process
+ #
+ # Args:
+ # messenger (buildstream._messenger.Messenger): Messenger to forward information to the frontend
+ #
+ def _terminate_casd_process(self, messenger=None):
+ self._casd_process.terminate()
+
+ try:
+ # Don't print anything if buildbox-casd terminates quickly
+ self._casd_process.wait(timeout=0.5)
+ except subprocess.TimeoutExpired:
+ if messenger:
+ cm = messenger.timed_activity("Terminating buildbox-casd")
+ else:
+ cm = contextlib.suppress()
+ with cm:
+ try:
+ self._casd_process.wait(timeout=15)
+ except subprocess.TimeoutExpired:
+ self._casd_process.kill()
+ self._casd_process.wait(timeout=15)
+
+ self._casd_process = None
+
# get_cache_usage():
#
# Fetches the current usage of the CAS local cache.