From b0fab7c5d062cd5a0b613fae2c4ffc60aad5c6fc Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Wed, 28 Aug 2024 17:27:12 -0700 Subject: [PATCH] Increase timeout for RemoteButler HTTP requests The default HTTPX timeout of 5 seconds is much too low when communicating with Butler server -- many requests can exceed that while waiting for the database to respond. --- python/lsst/daf/butler/remote_butler/_factory.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/lsst/daf/butler/remote_butler/_factory.py b/python/lsst/daf/butler/remote_butler/_factory.py index b872d2fa86..de18a5b4e5 100644 --- a/python/lsst/daf/butler/remote_butler/_factory.py +++ b/python/lsst/daf/butler/remote_butler/_factory.py @@ -66,7 +66,18 @@ def __init__(self, server_url: str, http_client: httpx.Client | None = None): if http_client is not None: self.http_client = http_client else: - self.http_client = httpx.Client() + self.http_client = httpx.Client( + # This timeout is fairly conservative. This value isn't the + # maximum amount of time the request can take -- it's the + # maximum amount of time to wait after receiving the last chunk + # of data from the server. + # + # Long-running, streamed queries send a keep-alive every 15 + # seconds. However, unstreamed operations like + # queryCollections can potentially take a while if the database + # is under duress. + timeout=120 # seconds + ) self._cache = RemoteButlerCache() @staticmethod