Use our own exception handler
Suppress harmless messages we cannot do anything about
This commit is contained in:
parent
b2672a4ae5
commit
33abea50d7
@ -19,6 +19,9 @@ from functools import partial
|
|||||||
from server.env import Env
|
from server.env import Env
|
||||||
from server.protocol import BlockServer
|
from server.protocol import BlockServer
|
||||||
|
|
||||||
|
SUPPRESS_MESSAGES = [
|
||||||
|
'Fatal read error on socket transport',
|
||||||
|
]
|
||||||
|
|
||||||
def main_loop():
|
def main_loop():
|
||||||
'''Start the server.'''
|
'''Start the server.'''
|
||||||
@ -34,6 +37,11 @@ def main_loop():
|
|||||||
logging.warning('received {} signal, shutting down'.format(signame))
|
logging.warning('received {} signal, shutting down'.format(signame))
|
||||||
future.cancel()
|
future.cancel()
|
||||||
|
|
||||||
|
def on_exception(loop, context):
|
||||||
|
message = context.get('message')
|
||||||
|
if not message in SUPPRESS_MESSAGES:
|
||||||
|
loop.default_exception_handler(context)
|
||||||
|
|
||||||
server = BlockServer(Env())
|
server = BlockServer(Env())
|
||||||
future = asyncio.ensure_future(server.main_loop())
|
future = asyncio.ensure_future(server.main_loop())
|
||||||
|
|
||||||
@ -42,6 +50,8 @@ def main_loop():
|
|||||||
loop.add_signal_handler(getattr(signal, signame),
|
loop.add_signal_handler(getattr(signal, signame),
|
||||||
partial(on_signal, signame))
|
partial(on_signal, signame))
|
||||||
|
|
||||||
|
# Install exception handler
|
||||||
|
loop.set_exception_handler(on_exception)
|
||||||
loop.run_until_complete(future)
|
loop.run_until_complete(future)
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user