#36662: django.contrib.messages Storage creates circular references with Request
objects
-------------------------------------+-------------------------------------
     Reporter:  Raphael Gaschignard  |                    Owner:  (none)
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  contrib.messages     |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Raphael Gaschignard:

Old description:

> To be honest I don't know how much people care about this kind of issue,
> but I am having some (very silly) operational issues downstream of
> Requests getting garbage collected at awkward times.
>

> Request objects hold onto message storages via Request._messages. The
> storage classes hold references back to Request. This creates a reference
> cycle preventing Requests from being collected as fast as they could be
> (and can create some awkwardness in CPython, with __del__ calls happening
> on associated objects in seemingly unrelated spots)
>
> The "simple" fix here would be to hold onto request in the storage
> through a weakref, and add a property to get the request object on the
> storage class.

New description:

 To be honest I don't know how much people care about this kind of issue,
 but I am having some (very silly) operational issues downstream of
 Requests getting garbage collected at awkward times.


 Request objects hold onto message storages via Request._messages. The
 storage classes hold references back to Request. This creates a reference
 cycle preventing Requests from being collected as fast as they could be
 (and can create some awkwardness in CPython, with __del__ calls happening
 on associated objects in seemingly unrelated spots)

 The "simple" fix here would be to hold onto request in the storage through
 a weakref, and add a property to get the request object on the storage
 class.

 [[Image(cycle.2.png)]]

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36662#comment:1>
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/01070199e165dfa4-59680241-0e5a-4c4a-a21e-1a068cc611fb-000000%40eu-central-1.amazonses.com.

Reply via email to