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

on_start Lifespan callback starts without event loop #140

Open
moznuy opened this issue Sep 13, 2023 · 1 comment
Open

on_start Lifespan callback starts without event loop #140

moznuy opened this issue Sep 13, 2023 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@moznuy
Copy link

moznuy commented Sep 13, 2023

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.

@cirospaciari cirospaciari added bug Something isn't working enhancement New feature or request labels Feb 1, 2024
@cirospaciari
Copy link
Owner

cirospaciari commented Feb 1, 2024

ASGI is being rewritten and this will be rewritten too, lifespan is too broken and hacky right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants