#35672: Using database connection pooling, threads do not return the connection
-------------------------------------+-------------------------------------
Reporter: André S. Hansen | Owner: (none)
Type: Bug | Status: new
Component: Database layer | Version: 5.1
(models, ORM) |
Severity: Normal | Resolution:
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):
Thanks for considering my case, and your questions and input, it helped
push me toward the solution.
> I assume your code was working before without the pool?
Yes
> What was the configuration then? Especially did you have persistent
connections enabled?
I did not specify CONN_MAX_AGE, meaning i had persistent connections
**disabled**.
---
After an hour of googling and testing I
[https://stackoverflow.com/questions/56584513/threads-in-django-test-case-
are-not-closing-db-connections found a decent solution]:
{{{
from django.db import connection
class TestThread(Thread):
def run(self) -> None:
super().run()
connection.close()
TestThread(target=RequestLog.objects.bulk_create,
args=(batched_logs,)).start()
}}}
The documentation https://docs.djangoproject.com/en/5.1/ref/databases/
could do well addressing this case. But i guess you can close this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/35672#comment:14>
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/0107019166bf326a-3ca1bdcd-6eb5-4438-88d7-6522d8a73773-000000%40eu-central-1.amazonses.com.