Fix warnings
This commit is contained in:
parent
48a2526d62
commit
d6059bdd2a
|
@ -499,13 +499,23 @@ class SynapseRequest(Request):
|
||||||
self.start_time = int(time.time() * 1000)
|
self.start_time = int(time.time() * 1000)
|
||||||
|
|
||||||
def finished_processing(self):
|
def finished_processing(self):
|
||||||
|
|
||||||
|
try:
|
||||||
|
context = LoggingContext.current_context()
|
||||||
|
ru_utime, ru_stime = context.get_resource_usage()
|
||||||
|
except:
|
||||||
|
ru_utime, ru_stime = (0, 0)
|
||||||
|
|
||||||
self.site.access_logger.info(
|
self.site.access_logger.info(
|
||||||
"%s - %s - {%s}"
|
"%s - %s - {%s}"
|
||||||
" Processed request: %dms %sB %s \"%s %s %s\" \"%s\"",
|
" Processed request: %dms (%dms, %dms)"
|
||||||
|
" %sB %s \"%s %s %s\" \"%s\"",
|
||||||
self.getClientIP(),
|
self.getClientIP(),
|
||||||
self.site.site_tag,
|
self.site.site_tag,
|
||||||
self.authenticated_entity,
|
self.authenticated_entity,
|
||||||
int(time.time() * 1000) - self.start_time,
|
int(time.time() * 1000) - self.start_time,
|
||||||
|
int(ru_utime * 1000),
|
||||||
|
int(ru_stime * 1000),
|
||||||
self.sentLength,
|
self.sentLength,
|
||||||
self.code,
|
self.code,
|
||||||
self.method,
|
self.method,
|
||||||
|
|
|
@ -23,6 +23,7 @@ try:
|
||||||
import resource
|
import resource
|
||||||
RUSAGE_THREAD = 1
|
RUSAGE_THREAD = 1
|
||||||
resource.getrusage(RUSAGE_THREAD)
|
resource.getrusage(RUSAGE_THREAD)
|
||||||
|
|
||||||
def get_thread_resource_usage():
|
def get_thread_resource_usage():
|
||||||
return resource.getrusage(RUSAGE_THREAD)
|
return resource.getrusage(RUSAGE_THREAD)
|
||||||
except:
|
except:
|
||||||
|
@ -137,13 +138,12 @@ class LoggingContext(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.usage_start:
|
if self.usage_start:
|
||||||
self.usage_end = get_thread_resource_usage()
|
self.usage_end = get_thread_resource_usage()
|
||||||
|
|
||||||
def get_resource_usage(self):
|
def get_resource_usage(self):
|
||||||
ru_utime = self.ru_utime
|
ru_utime = self.ru_utime
|
||||||
ru_stime = self.ru_stime
|
ru_stime = self.ru_stime
|
||||||
|
|
||||||
start = self.usage_start
|
|
||||||
if self.usage_start and threading.current_thread() is self.main_thread:
|
if self.usage_start and threading.current_thread() is self.main_thread:
|
||||||
current = get_thread_resource_usage()
|
current = get_thread_resource_usage()
|
||||||
ru_utime += current.ru_utime - self.usage_start.ru_utime
|
ru_utime += current.ru_utime - self.usage_start.ru_utime
|
||||||
|
|
Loading…
Reference in New Issue