[Django] #35130: Document how to manually close database connections

10 views
Skip to first unread message

Django

unread,
Jan 19, 2024, 8:04:10 AMJan 19
to django-...@googlegroups.com
#35130: Document how to manually close database connections
------------------------------------------------+------------------------
Reporter: Baptiste Mispelon | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I was reading about manual database connection management today and came
upon this section (emphasis mine) [1]:

> If a connection is created in a long-running process, outside of
Django’s request-response cycle, the connection will remain open **until
explicitly closed**, or timeout occurs.

From what I understand, manually closing open db connections is done by
calling `django.db.close_old_connections()`, but that function does not
seem to be documented officially.
I'm not sure if the function is undocumented by design (it is after all a
pretty unusual use-case and most users should never have to call it
themselves), or if that was just an omission.

[1] https://docs.djangoproject.com/en/dev/ref/databases/#caveats

--
Ticket URL: <https://code.djangoproject.com/ticket/35130>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 22, 2024, 12:13:43 AMJan 22
to django-...@googlegroups.com
#35130: Document how to manually close database connections
--------------------------------------+------------------------------------

Reporter: Baptiste Mispelon | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* stage: Unreviewed => Accepted


Comment:

I think it's fine to at least mention it in the "Caveats" section.

--
Ticket URL: <https://code.djangoproject.com/ticket/35130#comment:1>

Django

unread,
Jan 22, 2024, 4:54:22 AMJan 22
to django-...@googlegroups.com
#35130: Document how to manually close database connections
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Salvo
Type: | Polizzi
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Salvo Polizzi):

* owner: nobody => Salvo Polizzi
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/35130#comment:2>

Django

unread,
Jan 22, 2024, 6:16:05 AMJan 22
to django-...@googlegroups.com
#35130: Document how to manually close database connections
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Salvo
Type: | Polizzi
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/17766 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/35130#comment:3>

Django

unread,
Jan 22, 2024, 7:32:16 AMJan 22
to django-...@googlegroups.com
#35130: Document how to manually close database connections
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Salvo
Type: | Polizzi
Cleanup/optimization | Status: closed
Component: Documentation | Version: 5.0
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"184d82d8488b1b31ade5b5a68b0040f1c267f2be" 184d82d]:
{{{
#!CommitTicketReference repository=""
revision="184d82d8488b1b31ade5b5a68b0040f1c267f2be"
Fixed #35130 -- Doc'd django.db.close_old_connections().

This also adds close_db_connections() to the django.db.__all__.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/35130#comment:4>

Reply all
Reply to author
Forward
0 new messages