Browse Source

profiling: fix for 'none'

Peter Bieringer 2 months ago
parent
commit
2df265617b
1 changed files with 7 additions and 10 deletions
  1. 7 10
      radicale/app/__init__.py

+ 7 - 10
radicale/app/__init__.py

@@ -36,7 +36,7 @@ import random
 import time
 import zlib
 from http import client
-from typing import Iterable, List, Mapping, Sequence, Tuple, Union
+from typing import Iterable, List, Mapping, Tuple, Union
 
 from radicale import config, httputils, log, pathutils, types
 from radicale.app.base import ApplicationBase
@@ -60,8 +60,6 @@ _IntermediateResponse = Tuple[str, List[Tuple[str, str]], Iterable[bytes]]
 
 REQUEST_METHODS = ["DELETE", "GET", "HEAD", "MKCALENDAR", "MKCOL", "MOVE", "OPTIONS", "POST", "PROPFIND", "PROPPATCH", "PUT", "REPORT"]
 
-PROFILING: Sequence[str] = ("per_request", "per_request_method")
-
 
 class Application(ApplicationPartDelete, ApplicationPartHead,
                   ApplicationPartGet, ApplicationPartMkcalendar,
@@ -134,14 +132,13 @@ class Application(ApplicationPartDelete, ApplicationPartHead,
         self._profiling_per_request_min_duration = configuration.get("logging", "profiling_per_request_min_duration")
         self._profiling_per_request_method_interval = configuration.get("logging", "profiling_per_request_method_interval")
         self._profiling_top_x_functions = configuration.get("logging", "profiling_top_x_functions")
-        if self._profiling == "per_request":
-            self._profiling_per_request = True
-        elif self._profiling == "per_request_method":
-            self._profiling_per_request_method = True
-        else:
-            logger.warning("profiling: %s (not supported, disabled)", self._profiling)
-        if self._profiling_per_request or self._profiling_per_request_method:
+        if self._profiling in config.PROFILING:
             logger.info("profiling: %s", self._profiling)
+            if self._profiling == "per_request":
+                self._profiling_per_request = True
+            elif self._profiling == "per_request_method":
+                self._profiling_per_request_method = True
+        if self._profiling_per_request or self._profiling_per_request_method:
             logger.info("profiling top X functions: %d", self._profiling_top_x_functions)
         if self._profiling_per_request:
             logger.info("profiling per request minimum duration: %d (below are skipped)", self._profiling_per_request_min_duration)