update_manager: timeout bug fixes
It shouldn't be necessary to use gen.with_timeout during the fetch with tornado 6.1. Also fix some potential issues with unbound timeouts variables. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
9501d72059
commit
fad6bc4ad7
|
@ -150,20 +150,17 @@ class UpdateManager:
|
||||||
if is_download:
|
if is_download:
|
||||||
content_type = "application/zip"
|
content_type = "application/zip"
|
||||||
rto = 120.
|
rto = 120.
|
||||||
timeout = cto + rto + 2.
|
|
||||||
request = HTTPRequest(url, headers={"Accept": content_type},
|
request = HTTPRequest(url, headers={"Accept": content_type},
|
||||||
connect_timeout=cto, request_timeout=rto)
|
connect_timeout=cto, request_timeout=rto)
|
||||||
retries = 5
|
retries = 5
|
||||||
while True:
|
while True:
|
||||||
to = IOLoop.current().time() + timeout
|
|
||||||
try:
|
try:
|
||||||
fut = self.http_client.fetch(request)
|
resp = await self.http_client.fetch(request)
|
||||||
resp = await tornado.gen.with_timeout(to, fut)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
retries -= 1
|
retries -= 1
|
||||||
if not retries:
|
if not retries:
|
||||||
raise
|
raise
|
||||||
logging.info(f"Github request error, retrying: {e}")
|
logging.exception(f"Github request error, retrying: {e}")
|
||||||
continue
|
continue
|
||||||
if is_download:
|
if is_download:
|
||||||
return resp.body
|
return resp.body
|
||||||
|
@ -247,8 +244,8 @@ class GitUpdater:
|
||||||
if self.init_evt.is_set():
|
if self.init_evt.is_set():
|
||||||
return
|
return
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
to = IOLoop.current().time() + timeout
|
timeout = IOLoop.current().time() + timeout
|
||||||
await self.init_evt.wait(to)
|
await self.init_evt.wait(timeout)
|
||||||
|
|
||||||
async def refresh(self):
|
async def refresh(self):
|
||||||
await self._check_version()
|
await self._check_version()
|
||||||
|
@ -273,7 +270,7 @@ class GitUpdater:
|
||||||
if branch is None:
|
if branch is None:
|
||||||
self._log_info(
|
self._log_info(
|
||||||
"Unable to retreive current branch from branch list\n"
|
"Unable to retreive current branch from branch list\n"
|
||||||
f"{branches}")
|
f"{blist}")
|
||||||
return
|
return
|
||||||
if "HEAD detached" in branch:
|
if "HEAD detached" in branch:
|
||||||
bparts = branch.split()[-1].strip("()")
|
bparts = branch.split()[-1].strip("()")
|
||||||
|
@ -532,8 +529,8 @@ class ClientUpdater:
|
||||||
if self.init_evt.is_set():
|
if self.init_evt.is_set():
|
||||||
return
|
return
|
||||||
if timeout is not None:
|
if timeout is not None:
|
||||||
to = IOLoop.current().time() + timeout
|
timeout = IOLoop.current().time() + timeout
|
||||||
await self.init_evt.wait(to)
|
await self.init_evt.wait(timeout)
|
||||||
|
|
||||||
async def refresh(self):
|
async def refresh(self):
|
||||||
# Local state
|
# Local state
|
||||||
|
|
Loading…
Reference in New Issue