#36700: ASGIHandler creates reference cycles that require a gc pass to free
-------------------------------------+-------------------------------------
Reporter: Patryk Zawadzki | Owner:
Type: | farthestmage
Cleanup/optimization | Status: closed
Component: HTTP handling | Version: 5.2
Severity: Normal | Resolution: fixed
Keywords: memory asgihandler | Triage Stage: Accepted
gc |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Joe Babbitt):
* cc: Joe Babbitt (added)
* resolution: => fixed
* status: assigned => closed
Comment:
It seems as though the
[https://github.com/django/django/commit/2501958b5127020411df6271445ccfd0906df70e
move to TaskGroups] back in Nov 2025 resolved this issue as `__aexit__`
cleans up references with the implementation even
[https://github.com/python/cpython/blob/main/Lib/asyncio/taskgroups.py#L77-L80
calling out] this exact behavior.
> Exceptions are heavy objects that can have object cycles (bad for GC);
let's not keep a reference to a bunch of them. It would be nicer to use a
try/finally in `__aexit__` directly but that introduced some diff noise
I believe this can be closed given this.
Writing a test for this functionality would essentially be testing the
CPython implementation of TaskGroups; especially given they are aware of
this exact issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/36700#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 visit
https://groups.google.com/d/msgid/django-updates/0107019e3c487ba8-115a7f03-b003-41c8-bd2e-3860adb296f9-000000%40eu-central-1.amazonses.com.