Opened 2 years ago

Last modified 2 years ago

#33755 closed Cleanup/optimization

Move ASGi body-file cleanup into ASGIRequest — at Initial Version

Reported by: Carlton Gibson Owned by: nobody
Component: HTTP handling Version: dev
Severity: Normal Keywords: ASGI
Cc: Jonas Lundberg Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django/core/handlers/asgi.py ASGIHandler.handle() currently creates a temporary file, body_file, and then maintains responsibility for closing that once the response is generated in an extend try...finally. In outline:

`
body_file = ...

try:

...

finally:

body_file.close()

`

The body_file is passed into the request, via create_request() and ASGIRequest.__init(). Conceptually the request object takes ownership of body_file at that point, and ideally it would be responsible for cleaning it up too, perhaps via a __del__ implementation.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top