avoid raise condition with parallel running profilers
This commit is contained in:
@@ -224,6 +224,7 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||||||
unsafe_path = environ.get("PATH_INFO", "")
|
unsafe_path = environ.get("PATH_INFO", "")
|
||||||
https = environ.get("HTTPS", "")
|
https = environ.get("HTTPS", "")
|
||||||
profiler = None
|
profiler = None
|
||||||
|
profiler_active = False
|
||||||
xml_request = None
|
xml_request = None
|
||||||
|
|
||||||
context = AuthContext()
|
context = AuthContext()
|
||||||
@@ -471,9 +472,19 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||||||
# Profiling
|
# Profiling
|
||||||
if self._profiling_per_request:
|
if self._profiling_per_request:
|
||||||
profiler = cProfile.Profile()
|
profiler = cProfile.Profile()
|
||||||
profiler.enable()
|
try:
|
||||||
|
profiler.enable()
|
||||||
|
except ValueError:
|
||||||
|
profiler_active = False
|
||||||
|
else:
|
||||||
|
profiler_active = True
|
||||||
elif self._profiling_per_request_method:
|
elif self._profiling_per_request_method:
|
||||||
self.profiler_per_request_method[request_method].enable()
|
try:
|
||||||
|
self.profiler_per_request_method[request_method].enable()
|
||||||
|
except ValueError:
|
||||||
|
profiler_active = False
|
||||||
|
else:
|
||||||
|
profiler_active = True
|
||||||
|
|
||||||
status, headers, answer, xml_request = function(
|
status, headers, answer, xml_request = function(
|
||||||
environ, base_prefix, path, user, remote_host, remote_useragent)
|
environ, base_prefix, path, user, remote_host, remote_useragent)
|
||||||
@@ -481,9 +492,11 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
|
|||||||
# Profiling
|
# Profiling
|
||||||
if self._profiling_per_request:
|
if self._profiling_per_request:
|
||||||
if profiler is not None:
|
if profiler is not None:
|
||||||
profiler.disable()
|
if profiler_active is True:
|
||||||
|
profiler.disable()
|
||||||
elif self._profiling_per_request_method:
|
elif self._profiling_per_request_method:
|
||||||
self.profiler_per_request_method[request_method].disable()
|
if profiler_active is True:
|
||||||
|
self.profiler_per_request_method[request_method].disable()
|
||||||
|
|
||||||
if (status, headers, answer, xml_request) == httputils.NOT_ALLOWED:
|
if (status, headers, answer, xml_request) == httputils.NOT_ALLOWED:
|
||||||
logger.info("Access to %r denied for %s", path,
|
logger.info("Access to %r denied for %s", path,
|
||||||
|
|||||||
Reference in New Issue
Block a user