Browse Source

Log fatal messages once only

master
Neil Booth 8 years ago
parent
commit
f43c08d979
  1. 15
      lib/jsonrpc.py

15
lib/jsonrpc.py

@ -324,12 +324,15 @@ class JSONSessionBase(util.LoggedClass):
Flag the connection to close on a fatal error or too many errors.''' Flag the connection to close on a fatal error or too many errors.'''
version = self.version version = self.version
self.error_count += 1 self.error_count += 1
if code in (version.PARSE_ERROR, version.INVALID_REQUEST): if not self.close_after_send:
self.log_info(message) fatal_log = None
self.close_after_send = True if code in (version.PARSE_ERROR, version.INVALID_REQUEST):
elif self.error_count >= 10: fatal_log = message
self.log_info('too many errors, last: {}'.format(message)) elif self.error_count >= 10:
self.close_after_send = True fatal_log = 'too many errors, last: {}'.format(message)
if fatal_log:
self.log_info(fatal_log)
self.close_after_send = True
return self.encode_payload(self.version.error_payload return self.encode_payload(self.version.error_payload
(message, code, id_)) (message, code, id_))

Loading…
Cancel
Save