Browse Source

Try to avoid asyncio log spew on shutdown

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)
master
Neil Booth 8 years ago
parent
commit
76b6899cf2
  1. 10
      server/controller.py

10
server/controller.py

@ -12,6 +12,7 @@ import os
import ssl import ssl
import time import time
import traceback import traceback
import warnings
from bisect import bisect_left from bisect import bisect_left
from collections import defaultdict from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
@ -247,6 +248,11 @@ class Controller(util.LoggedClass):
await self.shutdown_event.wait() await self.shutdown_event.wait()
self.logger.info('shutting down') self.logger.info('shutting down')
await self.shutdown() 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') self.logger.info('shutdown complete')
def initiate_shutdown(self): def initiate_shutdown(self):
@ -543,7 +549,7 @@ class Controller(util.LoggedClass):
def lookup_session(self, session_id): def lookup_session(self, session_id):
try: try:
session_id = int(session_id) session_id = int(session_id)
except: except Exception:
pass pass
else: else:
for session in self.sessions: for session in self.sessions:
@ -617,7 +623,7 @@ class Controller(util.LoggedClass):
if isinstance(address, str): if isinstance(address, str):
try: try:
return self.coin.address_to_hashX(address) return self.coin.address_to_hashX(address)
except: except Exception:
pass pass
raise RPCError('{} is not a valid address'.format(address)) raise RPCError('{} is not a valid address'.format(address))

Loading…
Cancel
Save