-
Notifications
You must be signed in to change notification settings - Fork 68
ASGI lifecycle events #187
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
Conversation
…ents to prevent deadlocks
Equivalent demo with quart from quart import Quart
app = Quart(__name__)
@app.route('/')
async def hello():
return 'hello'
@app.before_serving
async def create_db_pool():
print("running quart startup 1")
@app.before_serving
async def use_g():
print("Run quart startup 2")
@app.while_serving
async def lifespan():
print("Initial startup")
yield
print("Shutting down quart")
@app.after_serving
async def create_db_pool():
print("running quart shutdown 1") |
…ent loops are used. Check call sequence at runtime
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #187 +/- ##
==========================================
- Coverage 93.35% 92.97% -0.39%
==========================================
Files 56 56
Lines 3116 3187 +71
Branches 633 649 +16
==========================================
+ Hits 2909 2963 +54
- Misses 128 137 +9
- Partials 79 87 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
def __del__(self): | ||
if self.startup_task_done: | ||
asyncio.run(self.middleware.notify_shutdown()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why for shutdown, we dont raise runtimeerror if shutdown does not succeed (similar to startup)?
This PR calls the lifecycle event for startup and shutdown for an ASGI application provided by the new V2 wrapper.
This FastAPI application:
And this
function_app.py
code:Will run the startup and shutdown events for the Functions worker process.
