#35672: Using database connection pooling raises PoolTimeout after a while
-------------------------------------+-------------------------------------
Reporter: André S. Hansen | Owner: (none)
Type: Bug | Status: closed
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by André S. Hansen):
I did some more testing and figured out the source of the problem. When i
disabled a Threaded connection to the database, the bug stopped happening.
My current theory is that the thread dont return the connection to the
pool. I am investigating now how i should properly do this with Threads.
Simplified version of code
{{{
class TimeMonitorMiddleware(object):
batched_logs: List[RequestLog] = []
def __call__(self, request: WSGIRequest) -> HttpResponse:
# ...
# Save batched logs
if len(self.batched_logs) >= 50:
Thread(target=RequestLog.objects.bulk_create,
args=(batched_logs,)).start()
return response
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35672#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701916516498d-2a11415f-8c7f-47c6-8b49-b79d62cf7c9f-000000%40eu-central-1.amazonses.com.