Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exiting not gracefully - trying to close stream writer after event loop is closed. #43

Open
idan-dagan-imagenai opened this issue Nov 28, 2023 · 2 comments

Comments

@idan-dagan-imagenai
Copy link

idan-dagan-imagenai commented Nov 28, 2023

So I am using python 3.11 and fastapi.. everything is working as expected but every time the process is exiting (uvicorn web server), i get the following traceback:
Exception ignored in: <function StreamWriter.del at 0x1008cd6c0>
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/streams.py", line 395, in del
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/streams.py", line 343, in close
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/selector_events.py", line 860, in close
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 761, in call_soon
File "/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 519, in _check_closed
RuntimeError: Event loop is closed

I had to add this lines of code inside shutdown to close the connection gracefully which will close the streamwriter related to the connection.
Is this is the right approach? what am I missing?

@idan-dagan-imagenai
Copy link
Author

image
Prettier version

@idan-dagan-imagenai
Copy link
Author

@classmethod
async def close(cls):
    await cls.redis.close()
    
   This method inside FastAPILimiter does not work because it does not close the connection inside the connection pool.. maybe add the option to add the flag from outside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant