Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

HH-25681 memory leak in loggerAdapter fix

  • Loading branch information...
commit ff94861e5da37941486ff2b5bf4a1f410e6cb087 1 parent 2221a2c
@katraev katraev authored
Showing with 14 additions and 7 deletions.
  1. +9 −2 frontik/handler.py
  2. +5 −5 frontik/handler_xml_debug.py
View
11 frontik/handler.py
@@ -90,9 +90,16 @@ def filter(self, record):
return True
log.addFilter(ContextFilter())
+
class PageLogger(logging.LoggerAdapter):
def __init__(self, logger_name, page, handler_name, zero_time):
- logging.LoggerAdapter.__init__(self, log, dict(request_id = logger_name, page = page, handler = handler_name))
+
+ class Logger4Adapter(logging.Logger):
+ def handle(self, record):
+ logging.Logger.handle(self, record)
+ log.handle(record)
+
+ logging.LoggerAdapter.__init__(self, Logger4Adapter('frontik.handler'), dict(request_id = logger_name, page = page, handler = handler_name))
self._time = zero_time
self.stages = []
self.page = page
@@ -446,7 +453,7 @@ def _fetch_request_response(self, placeholder, callback, request, response, requ
size=' {0:e} bytes'.format(len(response.body)) if response.body is not None else '',
time=response.request_time * 1000
),
- extra = {"response": response, "request": request}
+ extra = {"_response": response, "_request": request}
)
if not request_types:
View
10 frontik/handler_xml_debug.py
@@ -139,13 +139,13 @@ def handle(self, record):
entry = etree.Element("entry", **entry_attrs)
entry.set("asctime", str(datetime.fromtimestamp(record.created)))
- if getattr(record, "response", False):
- entry.append(response_to_xml(record.response))
+ if getattr(record, "_response", False):
+ entry.append(response_to_xml(record._response))
- if getattr(record, "request", False):
- entry.append(request_to_xml(record.request))
+ if getattr(record, "_request", False):
+ entry.append(request_to_xml(record._request))
- if getattr(record, "xml", False):
+ if getattr(record, "_xml", False):
xml = etree.Element("xml")
entry.append(xml)
# make deepcopy
Please sign in to comment.
Something went wrong with that request. Please try again.