#34865: DatabaseWrapper are not GC and connections are not closed
-------------------------------------+-------------------------------------
     Reporter:  Fábio Domingues      |                    Owner:  Priyank
                                     |  Panchal
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Florian Apolloner):

 Thinking more about this ticket (please note that I am thinking out loud
 here, so let me know if take a wrong turn somewhere): `DatabaseWrapper` is
 in a standard setup *not* supposed to get garbage collected at all. Each
 thread will have one wrapper per defined database stored in a thread local
 (`ConnectionHandler`/`BaseConnectionHandler`). So unless the "web"server
 is spawning a new thread per connection this should not be a problem (I
 could see it being a problem for runserver but that is for dev only
 anyways).

 So to the people having issues here: Where exactly are you seeing this, in
 job queues (celery etc) or in your webservers (which exactly). Fábio
 mentioned seeing it on uvicorn / daphne, is this also a problem for
 gunicorn (I know that one usually has a fixed worker & thread count
 there).

 Please note that I am not saying that there is no problem hidden here, the
 cyclic reference is certainly ugly. But if the object isn't ment to get
 garbage collected, it is not the end of the world. That said I would
 certainly prefer a solution that doesn't use a weakref proxy (we would
 need to do some profiling on the overhead).
-- 
Ticket URL: <https://code.djangoproject.com/ticket/34865#comment:17>
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 visit 
https://groups.google.com/d/msgid/django-updates/01070194e5e3c494-74194af1-ec8b-46ef-8afd-7220daa1675f-000000%40eu-central-1.amazonses.com.

Reply via email to