Skip to content

Commit ba726ef

Browse files
authored
Python: Make sure to log errors from async handlers (#2820)
## Motivation and Context We were skipping logging of the errors occurred during execution of asynchronous Python handlers due to the question mark at the end: ``` result.await.map(|r| #{pyo3}::Python::with_gil(|py| r.extract::<$output>(py)))? // <- ``` Any exception thrown in asynchronous Python handlers will be logged properly with this change. ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 1de3802 commit ba726ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class PythonServerOperationHandlerGenerator(
115115
};
116116
#{pyo3_asyncio}::tokio::into_future(coroutine)
117117
})?;
118-
result.await.map(|r| #{pyo3}::Python::with_gil(|py| r.extract::<$output>(py)))?
118+
result.await.and_then(|r| #{pyo3}::Python::with_gil(|py| r.extract::<$output>(py)))
119119
""",
120120
*codegenScope,
121121
)

0 commit comments

Comments
 (0)