Use a regex for message suppression
This commit is contained in:
parent
09e840de3c
commit
1956b9d659
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -27,11 +28,7 @@ class ServerBase(object):
|
|||||||
Upon return the event loop runs until the shutdown signal is received.
|
Upon return the event loop runs until the shutdown signal is received.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
SUPPRESS_MESSAGES = [
|
SUPPRESS_MESSAGE_REGEX = re.compile('SSH handshake')
|
||||||
'Fatal read error on socket transport',
|
|
||||||
'Fatal write error on socket transport',
|
|
||||||
]
|
|
||||||
|
|
||||||
PYTHON_MIN_VERSION = (3, 6)
|
PYTHON_MIN_VERSION = (3, 6)
|
||||||
|
|
||||||
def __init__(self, env):
|
def __init__(self, env):
|
||||||
@ -69,9 +66,7 @@ class ServerBase(object):
|
|||||||
def on_exception(self, loop, context):
|
def on_exception(self, loop, context):
|
||||||
'''Suppress spurious messages it appears we cannot control.'''
|
'''Suppress spurious messages it appears we cannot control.'''
|
||||||
message = context.get('message')
|
message = context.get('message')
|
||||||
if message in self.SUPPRESS_MESSAGES:
|
if message and self.SUPPRESS_MESSAGE_REGEX.match(message):
|
||||||
return
|
|
||||||
if 'accept_connection2()' in repr(context.get('task')):
|
|
||||||
return
|
return
|
||||||
loop.default_exception_handler(context)
|
loop.default_exception_handler(context)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user