Skip to content

Commit 2a376d3

Browse files
authored
Improve description of Python return serialization
1 parent 81a2bd0 commit 2a376d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc_source/python-programming-model-handler-types.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ In the syntax, note the following:
1212
+ `event` – AWS Lambda uses this parameter to pass in event data to the handler\. This parameter is usually of the Python `dict` type\. It can also be `list`, `str`, `int`, `float`, or `NoneType` type\.
1313
+ `context` – AWS Lambda uses this parameter to provide runtime information to your handler\. This parameter is of the `LambdaContext` type\.
1414
+ Optionally, the handler can return a value\. What happens to the returned value depends on the invocation type you use when invoking the Lambda function:
15-
+ If you use the `RequestResponse` invocation type \(synchronous execution\), AWS Lambda returns the result of the Python function call to the client invoking the Lambda function \(in the HTTP response to the invocation request, serialized into JSON\)\. For example, AWS Lambda console uses the `RequestResponse` invocation type, so when you invoke the function using the console, the console will display the returned value\.
15+
+ If you use the `RequestResponse` invocation type \(synchronous execution\), AWS Lambda returns the result of the Python function call to the client invoking the Lambda function \(in the HTTP response to the invocation request, serialized into JSON via `json.dumps`\)\. For example, AWS Lambda console uses the `RequestResponse` invocation type, so when you invoke the function using the console, the console will display the returned value\.
1616

17-
If the handler returns `NONE`, AWS Lambda returns null\.
17+
If the handler returns objects that can't be serialized by `json.dumps`, the Lambda runtime will crash and the invocation will fail.
18+
19+
If the handler returns `None`, as Python functions with a `return` statement implicitly do, this gets serializes this as JSON `null`\.
1820
+ If you use the `Event` invocation type \(asynchronous execution\), the value is discarded\.
1921

2022
For example, consider the following Python example code\.
@@ -52,4 +54,4 @@ This example has one function called `my_handler`\. The function returns a messa
5254
--runtime python3.6 \
5355
--timeout 15 \
5456
--memory-size 512
55-
```
57+
```

0 commit comments

Comments
 (0)