Revert "Add a django middleware to cleanup db connections."
This ended up being useless because of the way startlette and fastapi do
thread pools. The middleware is called in one thread, the path in
another, and the dependency in yet another.
This reverts commit 473448246f
.
master
parent
6738c2cf20
commit
6ec03c3d34
@ -1,15 +0,0 @@
|
||||
from starlette.types import ASGIApp, Receive, Scope, Send
|
||||
from django.db import close_old_connections, reset_queries
|
||||
|
||||
|
||||
class DjangoDbConnectionCleanupMiddleware:
|
||||
def __init__(self, app: ASGIApp):
|
||||
self.app = app
|
||||
|
||||
async def __call__(self, scope: Scope, receive: Receive, send: Send):
|
||||
reset_queries()
|
||||
close_old_connections()
|
||||
try:
|
||||
await self.app(scope, receive, send)
|
||||
finally:
|
||||
close_old_connections()
|
Loading…
Reference in New Issue