-
Notifications
You must be signed in to change notification settings - Fork 7
enhancement: Add Lifespan Events Handling In ASGI app #113
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
enhancement: Add Lifespan Events Handling In ASGI app #113
Conversation
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.
Hey, thank you for creating this PR, i did a first pass and it looks good!
I’d need to verify the lambda path + lifespan, we need to make sure that it still make sense.
Imagine a user that use aws lambda and they provide a lifespan.
Let me take another look later.
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.
Thanks a lot @objecthuman, that looks like a great improvement.
I've tested this with hypercorn and uvicorn with and without a lifespan set,
and all seems to be working.
I have one question regarding state
, and also an ask about adding event type assertions.
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.
Great work @objecthuman! I've tried this out locally with and without the lifespan both with unicorn and hypercorn and it works great.
@objecthuman just before merging this, can you please rebase on main? it seems like there are some commits that are already in main. |
![]() |
Add Lifespan Events Handling in ASGI app
Description
This PR adds handling of lifespan events for the restate ASGI app.
Why is this change being introduced?
Any application that has any type of long-running network connection needs to close the connection that it created at startup. Currently the restate python sdk does not support handling of application lifespan. By adding support for lifespan handling, we allow application developers to close any long running connection that they might have opened.
Changes Introduced
Code Changes
lifespan_processor
function to execute the lifespan function.lifespan_process
function.Example usage: