socketify.py
socketify.py copied to clipboard
on_start Lifespan callback starts without event loop
Describe the bug
on_start lifespan callback starts without event loop.
To Reproduce It's strange because sources already contain "test" file for lifespan, but for some reason lifespan is set to False. Steps to reproduce the behavior:
docker run -it --rm python:3.10-slim bash
apt-get update && apt-get install git libuv1 zlib1g -y
git clone https://github.com/cirospaciari/socketify.py.git && cd socketify.py
# Last commit on main branch when this issue was created
git checkout e8b4c21515a32f2d99c7d93755e4d40187aceb3e
pip install -e .
sed -i 's\lifespan=False\lifespan=True\g' src/tests.py
python src/tests.py
Expected behavior
Lifecycle event on_start functions normally
Screenshots
wait...
ERROR:root:Uncaught Exception: no running event loop
Listening on port http://localhost:3000 now
Desktop (please complete the following information):
- OS: ~Ubuntu~ Docker
- CPython 3.10
- Latest commit on the main branch
Additional context Probably related to #135 and #137
P.S. It would be great to allow register @asynccontextmanager, like aiohttp cleanup_ctx or FastAPI lifespan but that is separate feature request.
ASGI is being rewritten and this will be rewritten too, lifespan is too broken and hacky right now.