#19519: Django fails to close db connections at end of request-response cycle -------------------------------------+------------------------------------- Reporter: amosonn@… | Owner: aaugustin Type: Bug | Status: assigned Component: Database layer | Version: master (models, ORM) | Resolution: Severity: Release blocker | Triage Stage: Ready for Keywords: connection, | checkin managment, closing, mysql, | Needs documentation: 0 innodb, signal, generator | Patch needs improvement: 0 Has patch: 1 | UI/UX: 0 Needs tests: 0 | Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by akaariai): I am wondering if pushing the request_finished signal to late stages is actually safe to do. Question no. 2 from pep 3333 [http://www.python.org/dev/peps/pep-3333/#questions-and-answers] says that: {{{ If we supported only the iteration approach, then current frameworks that assume the availability of "push" suffer. But, if we only support pushing via write(), then server performance suffers for transmission of e.g. large files (if a worker thread can't begin work on a new request until all of the output has been sent). Thus, this compromise allows an application framework to support both approaches, as appropriate, but with only a little more burden to the server implementor than a push-only approach would require. }}} To me this suggest it is possible a different thread will finish the request and/or there is another request processed at the same time by the same thread. This would mean that we could be closing connections for different threads or different requests. I hope I am 100% wrong here. If the above is the case, this is going to get a lot more complex. The connection handling is bound to threads, not requests. What we could do is detach the connection from the thread at the old request_finished point, and then when the request is actually finished (the new request_finished point) we could close the connection. -- Ticket URL: <https://code.djangoproject.com/ticket/19519#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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.