Skip to content

Commit

Permalink
Try to avoid asyncio log spew on shutdown
Browse files Browse the repository at this point in the history
Closes #106.
This is a hacky workaround to an issue that needs to be
fixed in Python's asyncio library (where I filed issue 487
on github)
  • Loading branch information
Neil Booth committed Jan 25, 2017
1 parent cb01609 commit 76b6899
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import ssl
import time
import traceback
import warnings
from bisect import bisect_left
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
Expand Down Expand Up @@ -247,6 +248,11 @@ async def main_loop(self):
await self.shutdown_event.wait()
self.logger.info('shutting down')
await self.shutdown()
# Avoid log spew on shutdown for partially opened SSL sockets
try:
del asyncio.sslproto._SSLProtocolTransport.__del__
except Exception:
pass
self.logger.info('shutdown complete')

def initiate_shutdown(self):
Expand Down Expand Up @@ -543,7 +549,7 @@ def session_data(self, for_log):
def lookup_session(self, session_id):
try:
session_id = int(session_id)
except:
except Exception:
pass
else:
for session in self.sessions:
Expand Down Expand Up @@ -617,7 +623,7 @@ def address_to_hashX(self, address):
if isinstance(address, str):
try:
return self.coin.address_to_hashX(address)
except:
except Exception:
pass
raise RPCError('{} is not a valid address'.format(address))

Expand Down

0 comments on commit 76b6899

Please sign in to comment.