Update public source
This commit is contained in:
@@ -13,6 +13,13 @@ class RequestLifecycleMiddleware:
|
||||
("POST", "/gps-test/stop"),
|
||||
}
|
||||
|
||||
UNTRACKED_DURING_SHUTDOWN = {
|
||||
("GET", "/"),
|
||||
("HEAD", "/"),
|
||||
("GET", "/api/status"),
|
||||
("GET", "/api/gps-test"),
|
||||
}
|
||||
|
||||
STATIC_PREFIXES = (
|
||||
"/static/",
|
||||
"/reports/static/",
|
||||
@@ -99,14 +106,15 @@ class RequestLifecycleMiddleware:
|
||||
method = environ.get("REQUEST_METHOD", "GET").upper()
|
||||
path = environ.get("PATH_INFO", "/")
|
||||
|
||||
track_request = True
|
||||
|
||||
with self._condition:
|
||||
|
||||
if (
|
||||
self._shutdown_requested
|
||||
and not self._is_allowed_during_shutdown(
|
||||
if self._shutdown_requested:
|
||||
|
||||
if not self._is_allowed_during_shutdown(
|
||||
method,
|
||||
path
|
||||
)
|
||||
):
|
||||
|
||||
body = b"Application is shutting down.\n"
|
||||
@@ -123,8 +131,28 @@ class RequestLifecycleMiddleware:
|
||||
|
||||
return [body]
|
||||
|
||||
if (
|
||||
(method, path) in self.UNTRACKED_DURING_SHUTDOWN
|
||||
or (
|
||||
method in ("GET", "HEAD")
|
||||
and any(
|
||||
path.startswith(prefix)
|
||||
for prefix in self.STATIC_PREFIXES
|
||||
)
|
||||
)
|
||||
):
|
||||
|
||||
track_request = False
|
||||
|
||||
if track_request:
|
||||
self._active_requests += 1
|
||||
|
||||
if not track_request:
|
||||
return self.application(
|
||||
environ,
|
||||
start_response
|
||||
)
|
||||
|
||||
try:
|
||||
|
||||
response = self.application(
|
||||
|
||||
Reference in New Issue
Block a user