[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
1dcb9ea8cd
commit
b2da1e070b
2 changed files with 18 additions and 15 deletions
|
|
@ -22,12 +22,14 @@ import structlog
|
|||
logger = structlog.get_logger(__name__)
|
||||
|
||||
# Paths and suffixes excluded from request logging.
|
||||
_EXCLUDED_PATHS = frozenset({
|
||||
"/api/train/status",
|
||||
"/api/train/metrics",
|
||||
"/api/train/hardware",
|
||||
"/api/system",
|
||||
})
|
||||
_EXCLUDED_PATHS = frozenset(
|
||||
{
|
||||
"/api/train/status",
|
||||
"/api/train/metrics",
|
||||
"/api/train/hardware",
|
||||
"/api/system",
|
||||
}
|
||||
)
|
||||
_EXCLUDED_SUFFIXES = (".png", ".jpg", ".jpeg", ".ico", ".woff", ".woff2", ".ttf")
|
||||
|
||||
|
||||
|
|
@ -64,10 +66,10 @@ class LoggingMiddleware:
|
|||
method = scope.get("method", "")
|
||||
logger.error(
|
||||
"request_failed",
|
||||
path=path,
|
||||
method=method,
|
||||
error=str(e),
|
||||
exc_info=True,
|
||||
path = path,
|
||||
method = method,
|
||||
error = str(e),
|
||||
exc_info = True,
|
||||
)
|
||||
raise
|
||||
|
||||
|
|
@ -83,10 +85,10 @@ class LoggingMiddleware:
|
|||
method = scope.get("method", "")
|
||||
logger.info(
|
||||
"request_completed",
|
||||
method=method,
|
||||
path=path,
|
||||
status_code=status_code,
|
||||
process_time_ms=round(process_time, 2),
|
||||
method = method,
|
||||
path = path,
|
||||
status_code = status_code,
|
||||
process_time_ms = round(process_time, 2),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import re as _re
|
|||
_queue_sentinel = object()
|
||||
_queue_error = object()
|
||||
|
||||
|
||||
async def _run_gen_to_queue(gen, cancel_event):
|
||||
"""Run a synchronous generator in a background thread, yield items via asyncio.Queue."""
|
||||
loop = asyncio.get_running_loop()
|
||||
|
|
@ -44,7 +45,7 @@ async def _run_gen_to_queue(gen, cancel_event):
|
|||
finally:
|
||||
loop.call_soon_threadsafe(q.put_nowait, _queue_sentinel)
|
||||
|
||||
thread = threading.Thread(target=_producer, daemon=True, name="sse-gen")
|
||||
thread = threading.Thread(target = _producer, daemon = True, name = "sse-gen")
|
||||
thread.start()
|
||||
|
||||
while True:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue