diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-07-30 15:47:33 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-07-30 15:47:33 +0000 |
commit | cdee3d0565e2d96952ad6b6c4c9478405f6f178a (patch) | |
tree | 2f5d976c6deaa0f43dce2e434bb7bf42cce78b90 | |
parent | 0ff177595e710ade7f79fe2fa7dff44167b8b324 (diff) | |
parent | 75b8cff0d022001904c38caf1f7e701cf9995e10 (diff) | |
download | buildstream-cdee3d0565e2d96952ad6b6c4c9478405f6f178a.tar.gz |
Merge branch 'abderrahim/timeout' into 'bst-1'
cascache.py: enable grpc keepalive pings
See merge request BuildStream/buildstream!1979
-rw-r--r-- | buildstream/_artifactcache/cascache.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/buildstream/_artifactcache/cascache.py b/buildstream/_artifactcache/cascache.py index c6efcf508..645f2dad7 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -41,6 +41,9 @@ from .._exceptions import CASError # Limit payload to 1 MiB to leave sufficient headroom for metadata. _MAX_PAYLOAD_BYTES = 1024 * 1024 +# How often is a keepalive ping sent to the server to make sure the transport is still alive +_KEEPALIVE_TIME_MS = 60000 + class _Attempt(): @@ -1012,7 +1015,8 @@ class CASRemote(): url = urlparse(self.spec.url) if url.scheme == 'http': port = url.port or 80 - self.channel = grpc.insecure_channel('{}:{}'.format(url.hostname, port)) + self.channel = grpc.insecure_channel('{}:{}'.format(url.hostname, port), + options=[("grpc.keepalive_time_ms", _KEEPALIVE_TIME_MS)]) elif url.scheme == 'https': port = url.port or 443 @@ -1037,7 +1041,8 @@ class CASRemote(): credentials = grpc.ssl_channel_credentials(root_certificates=server_cert_bytes, private_key=client_key_bytes, certificate_chain=client_cert_bytes) - self.channel = grpc.secure_channel('{}:{}'.format(url.hostname, port), credentials) + self.channel = grpc.secure_channel('{}:{}'.format(url.hostname, port), credentials, + options=[("grpc.keepalive_time_ms", _KEEPALIVE_TIME_MS)]) else: raise CASError("Unsupported URL: {}".format(self.spec.url)) |