8000 perf(activity): write request rows off the event loop by adeelahmad · Pull Request #132 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion fastapi_backend/app/domain/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from __future__ import annotations

import asyncio
import contextlib
import contextvars
import datetime as dt
Expand Down Expand Up @@ -289,7 +290,8 @@ async def sending(message):
raise
finally:
try:
self._log(scope_, app, db, status[0], error, t0, head[0])
# off the event loop: the reply is already sent, and the write shouldn't hold up other requests
await asyncio.to_thread(self._log, scope_, app, db, status[0], error, t0, head[0])
finally:
_scope.reset(token)

Expand Down
Loading
0