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

Add async post_start method to ExtensionApp #1203

Open
Zsailer opened this issue Feb 6, 2023 · 3 comments · May be fixed by #1417
Open

Add async post_start method to ExtensionApp #1203

Zsailer opened this issue Feb 6, 2023 · 3 comments · May be fixed by #1417

Comments

@Zsailer
Copy link
Member

Zsailer commented Feb 6, 2023

Problem

I'm working on server extension that needs to trigger an asyncio.Task as soon as the Tornado Web Server starts. (If I try to start it any sooner, we'll get the infamous RuntimeError: no running event loop). Currently, there is no easy way to do this using the provided Server Extension API.

Proposed Solution

I'd like to propose that we add a async def post_start(...) method/API to the ExtensionApp that can be used by authors to trigger tasks after the webserver (and presumably the main event loop) is started. This works nicely with the async def stop() API that's already in-place to cleanly stop async tasks in server extensions.

@davidbrochart
Copy link
Contributor

FastAPI has startup and shutdown events, I don't know if it makes sense to have a similar API?

@fcollonval
Copy link
Member

I ran exactly in the same issue 😉 that would be a great addition

@oliver-sanders
Copy link
Contributor

This has also come up in #1329

@Zsailer Zsailer linked a pull request Apr 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants