mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-02-17 02:46:49 +00:00
Handle graceful exit and timeout
Timeout was refactored and the defaults work correctly here.
This commit is contained in:
parent
e3d62d4169
commit
c1e5822f07
@ -2,6 +2,7 @@
|
||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||
|
||||
import atexit
|
||||
import asyncio
|
||||
import aiohttp
|
||||
connector = aiohttp.TCPConnector(limit=20)
|
||||
|
||||
@ -24,5 +25,9 @@ class BetterClientSession(aiohttp.ClientSession):
|
||||
raise HTTPError(res.status, res.reason, res)
|
||||
return res
|
||||
|
||||
session = BetterClientSession(connector=connector, read_timeout=10, conn_timeout=5)
|
||||
atexit.register(session.close)
|
||||
session = BetterClientSession(connector=connector)
|
||||
|
||||
@atexit.register
|
||||
def cleanup():
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(session.close())
|
||||
|
Loading…
Reference in New Issue
Block a user