#32416: LiveServerTestCase's ThreadedWSGIServer doesn't close database 
connections
after each thread
-----------------------------------+------------------------------------
     Reporter:  Chris Jerdonek     |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  2.2
     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
-----------------------------------+------------------------------------

Comment (by Chris Jerdonek):

 It looks like this issue's fix might be as simple as adding the following
 method to Django's `ThreadedWSGIServer` (code:
 
https://github.com/django/django/blob/50a5f8840fa564dcefdb1fa5c58f06fcd472ee70/django/core/servers/basehttp.py#L80-L82)
 (it seems to be fixing it for me):

 {{{#!python
 from django.db import connections

 def close_request(self, request):
     """Called to clean up an individual request."""
     connections.close_all()
     super().close_request(request)
 }}}

 CPython's `socketserver` module documentation confirms the method is meant
 to be overridden:
 https://github.com/python/cpython/blob/v3.9.1/Lib/socketserver.py#L165-L175

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32416#comment:6>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.13cf22e8c4b7eb6c594ab868df670f05%40djangoproject.com.

Reply via email to