-
Notifications
You must be signed in to change notification settings - Fork 196
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
Lambda support for Python servers #1807
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
7641106
to
c1cae65
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
||
-app.run() | ||
+app.run_lambda() |
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.
What do you think about renaming the entrypoint of the standard server from run()
to run_server()
?
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.
I think run()
is clearer. I don't know if it is idiomatic but, if we decide to unify run_lambda
and any possible run_*
versions into a big run
function with keyword arguments like run(lambda=True, foo="bar", ...)
that would allow us to do without renaming it again.
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.
Ok, makes sense!
@@ -22,6 +22,7 @@ bytes = "1.2" | |||
futures = "0.3" | |||
http = "0.2" | |||
hyper = { version = "0.14.20", features = ["server", "http1", "http2", "tcp", "stream"] } | |||
lambda_http = "0.6.0" |
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.
Not a blocker for this PR, but I would probably create an issue to feature-gate lambda in the future so that we do not impose this dependency on all customers. I am not even sure if its worth it thou.. Thoughts?
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.
Yes good point. But I'm not sure if we currently support to generate SDKs with specific features on dependencies?
35d40d6
to
2b2876d
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
This looks good and I am very happy to see we can use this from the pure python lambda context! Are you planning to add an example of the Python code here?
By example code you mean like having Lambda example of Pokemon service? If so, I think there is no need for that because only code change is changing |
83b7a96
to
576faf7
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
ba5576c
to
5e5f672
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
5e5f672
to
424f9f5
Compare
516fbd1
to
32c8521
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
This PR exposes
app.run_lambda()
function to allow Python servers to run on Lambda. Closes #1750.Why we use custom Rust runtime
We could also use builtin Python runtime, I decided to use custom Rust runtime because there was some performance overheads.
If you use Python runtime:
lambda_http
crate but it is not designed to be reusable and requires some modification/copying (Rust)If you use Rust runtime:
lambda_http
crate) (Rust)Testing
It can be tested with a
Dockerfile
similar to this: