fix that aiohttp uses 'read()' on response, but tornado doesn't
This commit is contained in:
parent
3226a76cfe
commit
19be32164f
|
@ -28,12 +28,10 @@ async def get_version(name, conf):
|
|||
sort_version_key = sort_version_keys[conf.get("sort_version_key", "parse_version")]
|
||||
|
||||
async with session.get(conf['url'], headers=headers, **kwargs) as res:
|
||||
version = None
|
||||
body = (await res.read()).decode(encoding)
|
||||
try:
|
||||
body = (await res.read()).decode(encoding)
|
||||
try:
|
||||
version = max(regex.findall(body), key=sort_version_key)
|
||||
except ValueError:
|
||||
logger.error('%s: version string not found.', name)
|
||||
finally:
|
||||
return name, version
|
||||
version = max(regex.findall(body), key=sort_version_key)
|
||||
except ValueError:
|
||||
version = None
|
||||
logger.error('%s: version string not found.', name)
|
||||
return name, version
|
||||
|
|
|
@ -59,5 +59,9 @@ class ResponseManager:
|
|||
async def json_response(self):
|
||||
return json.loads(self.body.decode('utf-8'))
|
||||
|
||||
async def read(self):
|
||||
return self.body
|
||||
|
||||
HTTPResponse.json = json_response
|
||||
HTTPResponse.read = read
|
||||
session = Session()
|
||||
|
|
Loading…
Reference in New Issue