Open Zsailer opened 1 year ago
FastAPI has startup and shutdown events, I don't know if it makes sense to have a similar API?
I ran exactly in the same issue :wink: that would be a great addition
This has also come up in https://github.com/jupyter-server/jupyter_server/issues/1329
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 infamousRuntimeError: 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 theasync def stop()
API that's already in-place to cleanly stop async tasks in server extensions.