Closed vytas7 closed 2 years ago
When solving this, note that we probably need to stay on the safe side, and offload .close()
to an executor, even though it is in most cases very fast. aiofiles
also opts to run .close()
in an executor: https://github.com/Tinche/aiofiles#usage.
Hey! Can I take this one?
Yes, you are welcome!
@s-kamil just checking if you are still working on fixing this bug?
This is now open for contributions again! (A great issue to get that last Hacktoberfest PR IMHO)
When using static routes with a
falcon.asgi.App
, it seems that the_AsyncFileReader
wrapper does not implement any.close()
method, so files are left open.On CPython, I wasn't able to demonstrate any practical impact of this bug as the file object in question is refcounted to 0 and garbage collected as soon as it goes out of scope. However, that isn't the case when running
uvicorn
on PyPy 3.7, as PyPy uses a different GC implementation.Test case in point: