```
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/33755>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old 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.
New 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.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33755#comment:1>