close event loop when we're done with it (request_many())

This commit is contained in:
jesopo 2019-07-08 13:59:48 +01:00
parent 81c7af8ab5
commit a1438abf66

View file

@ -127,12 +127,13 @@ def request_many(urls: typing.List[str]) -> typing.Dict[str, Response]:
data = response.body.decode("utf8")
responses[url] = Response(response.code, data, headers)
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
awaits = []
for url in urls:
awaits.append(_request(url))
task = asyncio.gather(*awaits, return_exceptions=True)
loop.run_until_complete(task)
loop.close()
return responses