emmett-framework / granian

A Rust HTTP server for Python applications
BSD 3-Clause "New" or "Revised" License
2.86k stars 83 forks source link

How to handle rsgi app startup and graceful shutdown? #253

Closed mayli closed 7 months ago

mayli commented 7 months ago

It seems the RSGI interface doesn't have lifespan support like asgi?

gi0baro commented 7 months ago

At the moment (RSGI 1.4) there's just support for an initialization method. Your app can have an __rsgi_init__ method which should accept loop as the only argument.

You can take a look at emmett (https://github.com/emmett-framework/emmett/blob/v2.5.9/emmett/app.py#L439-L440) for an example. There are currently no plans to support a shutdown event, unless specific use-cases emerge for that.