From 1956b9d659345ed4dd1145ed8677edafaf07e4ce Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Mon, 6 Aug 2018 14:55:25 +0900 Subject: [PATCH] Use a regex for message suppression --- electrumx/lib/server_base.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/electrumx/lib/server_base.py b/electrumx/lib/server_base.py index 5b14d3c..6d6f66a 100644 --- a/electrumx/lib/server_base.py +++ b/electrumx/lib/server_base.py @@ -7,6 +7,7 @@ import asyncio import os +import re import signal import sys import time @@ -27,11 +28,7 @@ class ServerBase(object): Upon return the event loop runs until the shutdown signal is received. ''' - SUPPRESS_MESSAGES = [ - 'Fatal read error on socket transport', - 'Fatal write error on socket transport', - ] - + SUPPRESS_MESSAGE_REGEX = re.compile('SSH handshake') PYTHON_MIN_VERSION = (3, 6) def __init__(self, env): @@ -69,9 +66,7 @@ class ServerBase(object): def on_exception(self, loop, context): '''Suppress spurious messages it appears we cannot control.''' message = context.get('message') - if message in self.SUPPRESS_MESSAGES: - return - if 'accept_connection2()' in repr(context.get('task')): + if message and self.SUPPRESS_MESSAGE_REGEX.match(message): return loop.default_exception_handler(context)