close event loop when we're done with it (request_many())
This commit is contained in:
parent
81c7af8ab5
commit
a1438abf66
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue