Opened 11 years ago
Closed 11 years ago
#22146 closed Bug (duplicate)
Database-Connections time out in long running Applications without request context.
Reported by: | kahnert | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you use the Django-ORM outside of request handling, in uWSGI mules for example, connections time out. The expected behavior would be to reconnect on the next command issued.
But because the checks for unusable connections is bound to request signals those get never called.
An easy solution would be to call self.close_if_unusable_or_obsolete()
at first in BaseDatabaseWrapper.ensure_connection
.
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
I'd say it's up to the application to close the connection when it knows it isn't going to use it for some time that may exceed the database's connection timeout :)
What database backend are you using? Isn't this a duplicate of #21597?
comment:3 by , 11 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Since this introduces an infinite recursion, I changed it to
if self.connection is not None and not self.is_usable(): self.close()
in my testing setup.