diff options
author | Abderrahim Kitouni <akitouni@gnome.org> | 2020-07-02 10:37:33 +0100 |
---|---|---|
committer | Abderrahim Kitouni <akitouni@gnome.org> | 2020-07-18 12:07:19 +0100 |
commit | 629bead0133df4554e224e25bf78689db270b6c8 (patch) | |
tree | 4dba742f09cae1bae886d70cd9f9cb77c2750208 | |
parent | 8d7ee1885e2c458c4f2edf113e5a2d990235f708 (diff) | |
download | buildstream-abderrahim/timeout.tar.gz |
cascache.py: enable grpc keepalive pingsabderrahim/timeout
This allows bst to detect when connections are dropped instead of hanging
indefinitely
-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 4f0d10da5..d7656521d 100644 --- a/buildstream/_artifactcache/cascache.py +++ b/buildstream/_artifactcache/cascache.py @@ -48,6 +48,9 @@ from . import ArtifactCache # 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(): @@ -1104,7 +1107,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 @@ -1129,7 +1133,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 ArtifactError("Unsupported URL: {}".format(self.spec.url)) |