From bdd270fa4a9276e30b3ac96b447faae3430b66c1 Mon Sep 17 00:00:00 2001 From: Arksine Date: Thu, 7 Jan 2021 20:27:23 -0500 Subject: [PATCH] update_manager: wrap calls to http.fetch in "gen.with_timeout" This is a workaround for an issue where the http client fails to propogate an exception back to the caller, hanging the update process. Signed-off-by: Eric Callahan --- moonraker/plugins/update_manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moonraker/plugins/update_manager.py b/moonraker/plugins/update_manager.py index e70bafd..213a3dc 100644 --- a/moonraker/plugins/update_manager.py +++ b/moonraker/plugins/update_manager.py @@ -295,9 +295,11 @@ class UpdateManager: retries = 5 while retries: try: - resp = await self.http_client.fetch( + timeout = time.time() + 10. + fut = self.http_client.fetch( url, headers=headers, connect_timeout=5., request_timeout=5., raise_error=False) + resp = await tornado.gen.with_timeout(timeout, fut) except Exception: retries -= 1 msg = f"Error Processing GitHub API request: {url}" @@ -346,9 +348,11 @@ class UpdateManager: retries = 5 while retries: try: - resp = await self.http_client.fetch( + timeout = time.time() + 130. + fut = self.http_client.fetch( url, headers={"Accept": "application/zip"}, connect_timeout=5., request_timeout=120.) + resp = await tornado.gen.with_timeout(timeout, fut) except Exception: retries -= 1 logging.exception("Error Processing Download")