#33497: Database persistent connections do not work with ASGI in 4.0
-------------------------------------+-------------------------------------
     Reporter:  Stenkar              |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  4.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ASGI; Database       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Florian Apolloner):

 Thinking more about this I do not think the problem is new. We have the
 same problem when persistent connections are used and a new thread is
 generated per request (for instance in runserver.py). Usually (ie with
 gunicorn etc) one has a rather "stable" pool of processes or requests; as
 soon as you switch to new threads per connection this will break. In ASGI
 this behavior is probably more pronounced since by definition every
 request is in it's own async task context which then propagates down to
 the db backend as new connection per request (which in turn will also
 never reuse connections because the "thread" ids change).

 All in all I think we are finally at the point where we need a connection
 pool in Django. I'd strongly recommend to use something like
 https://github.com/psycopg/psycopg/tree/master/psycopg_pool/psycopg_pool
 but abstracted to work for all databases in Django.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33497#comment:8>
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/064.91053f1b76664405463a4b3f47a725a0%40djangoproject.com.

Reply via email to