#36662: django.contrib.messages Storage creates circular references with Request
objects
-------------------------------------+-------------------------------------
Reporter: Raphael Gaschignard | Type:
| Cleanup/optimization
Status: new | Component:
| contrib.messages
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/36662>
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/01070199e1633409-ef6d64e7-cc70-412b-aec0-a9b77461685a-000000%40eu-central-1.amazonses.com.