diff --git a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt index e8a704ecdd3b1bfb3f2faa553c06824d8134504a..d9ab006b0d581e9cc0946ce582f21be7a35214a2 100644 --- a/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt +++ b/codegen-server/python/src/main/kotlin/software/amazon/smithy/rust/codegen/server/python/smithy/generators/PythonServerOperationHandlerGenerator.kt @@ -115,7 +115,7 @@ class PythonServerOperationHandlerGenerator( }; #{pyo3_asyncio}::tokio::into_future(coroutine) })?; - result.await.map(|r| #{pyo3}::Python::with_gil(|py| r.extract::<$output>(py)))? + result.await.and_then(|r| #{pyo3}::Python::with_gil(|py| r.extract::<$output>(py))) """, *codegenScope, )