diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a3d8a25..731d580 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -1,3 +1,9 @@ +version 0.7.20 +-------------- + +- fix for errors during batch requests (issue #54) +- don't log errors on shutdown after giving sockets time to close + version 0.7.19 -------------- diff --git a/electrumx_server.py b/electrumx_server.py index 7129a8a..a749949 100755 --- a/electrumx_server.py +++ b/electrumx_server.py @@ -41,7 +41,7 @@ def main_loop(): def on_exception(loop, context): '''Suppress spurious messages it appears we cannot control.''' message = context.get('message') - if not message in SUPPRESS_MESSAGES: + if not loop.is_closed() and not message in SUPPRESS_MESSAGES: if not ('task' in context and 'accept_connection2()' in repr(context.get('task'))): loop.default_exception_handler(context) diff --git a/lib/jsonrpc.py b/lib/jsonrpc.py index 6329a83..5688f84 100644 --- a/lib/jsonrpc.py +++ b/lib/jsonrpc.py @@ -211,16 +211,17 @@ class JSONRPC(asyncio.Protocol, LoggedClass): if self.transport.is_closing(): return + id_ = payload.get('id') if isinstance(payload, dict) else None try: data = (json.dumps(payload) + '\n').encode() except TypeError: msg = 'JSON encoding failure: {}'.format(payload) self.logger.error(msg) - self.send_json_error(msg, self.INTERNAL_ERROR, payload.get('id')) + self.send_json_error(msg, self.INTERNAL_ERROR, id_) else: if len(data) > max(1000, self.max_send): - self.send_json_error('request too large', self.INVALID_REQUEST, - payload.get('id')) + self.send_json_error('request too large', + self.INVALID_REQUEST, id_) raise self.LargeRequestError else: self.send_count += 1 diff --git a/server/protocol.py b/server/protocol.py index bae092d..20157a8 100644 --- a/server/protocol.py +++ b/server/protocol.py @@ -341,7 +341,7 @@ class ServerManager(util.LoggedClass): if self.sessions: await self.close_sessions() - async def close_sessions(self, secs=60): + async def close_sessions(self, secs=30): self.logger.info('cleanly closing client sessions, please wait...') for session in self.sessions: self.close_session(session) diff --git a/server/version.py b/server/version.py index 0aa8848..c901cc6 100644 --- a/server/version.py +++ b/server/version.py @@ -1 +1 @@ -VERSION = "ElectrumX 0.7.19" +VERSION = "ElectrumX 0.7.20"