summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-11-04 15:50:58 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-11-04 15:50:58 +0000
commit9f713136d886473332897d96709a5f83209938ff (patch)
tree40cd3cfdd3277baf323be737c5ae6b9594f50091
parentabd09a9319376f40c7c05417338e70d5f2304f4a (diff)
parentaf9e54a6cdbb2f4b036afae53ea738717dc1ed17 (diff)
downloadbuildstream-9f713136d886473332897d96709a5f83209938ff.tar.gz
Merge branch 'juerg/casd-connect' into 'master'
cascache.py: Defer attempt to connect to casd until socket file exists See merge request BuildStream/buildstream!1667
-rw-r--r--src/buildstream/_cas/cascache.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index eb28e2df2..4ee575d05 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -140,25 +140,21 @@ class CASCache():
assert self._casd_process, "CASCache was instantiated without buildbox-casd"
if not self._casd_channel:
+ while not os.path.exists(self._casd_socket_path):
+ # casd is not ready yet, try again after a 10ms delay,
+ # but don't wait for more than 15s
+ if time.time() > self._casd_start_time + 15:
+ raise CASCacheError("Timed out waiting for buildbox-casd to become ready")
+
+ time.sleep(0.01)
+
self._casd_channel = grpc.insecure_channel('unix:' + self._casd_socket_path)
self._casd_cas = remote_execution_pb2_grpc.ContentAddressableStorageStub(self._casd_channel)
self._local_cas = local_cas_pb2_grpc.LocalContentAddressableStorageStub(self._casd_channel)
# Call GetCapabilities() to establish connection to casd
capabilities = remote_execution_pb2_grpc.CapabilitiesStub(self._casd_channel)
- while True:
- try:
- capabilities.GetCapabilities(remote_execution_pb2.GetCapabilitiesRequest())
- break
- except grpc.RpcError as e:
- if e.code() == grpc.StatusCode.UNAVAILABLE:
- # casd is not ready yet, try again after a 10ms delay,
- # but don't wait for more than 15s
- if time.time() < self._casd_start_time + 15:
- time.sleep(1 / 100)
- continue
-
- raise
+ capabilities.GetCapabilities(remote_execution_pb2.GetCapabilitiesRequest())
# _get_cas():
#