Repository navigation
Closed
Copy link
Labels
Description
Use case
With the full async pipeline built internally (PRs 1-4), this final PR exposes resolve_async() to customers, enabling native async handler support in all Event Handler resolvers.
Solution/User Experience
app = APIGatewayHttpResolver()
# Sync - works exactly as before
@app.get("/health")
def health():
return {"status": "ok"}
# Async - native support
@app.get("/dashboard/<user_id>")
async def get_dashboard(user_id: str):
orders, profile = await asyncio.gather(
get_orders(user_id),
get_profile(user_id),
)
return {"orders": orders, "profile": profile}
def lambda_handler(event, context):
return asyncio.run(app.resolve_async(event, context))What changes:
- Add public
resolve_async(event, context)method onApiGatewayResolver- Mirrors
resolve()setup (proxy event construction, context population, CORS, etc.) - Delegates to
_resolve_async()from PR 4
- Mirrors
- Add
resolve_async()to all resolver subclasses:APIGatewayRestResolver,APIGatewayHttpResolver,ALBResolver - Documentation and examples
- E2E tests
What stays the same:
resolve()is untouched - fully backward compatible- Sync and async handlers work in the same app
- All existing middlewares (sync) work without changes
- OpenAPI validation works with async handlers
- Route matching, serialization, compression - all CPU-bound, stay sync
Key design decisions:
resolve_async()is a new method, not a flag - explicit is better than implicit- Sync middlewares work in async chain - threading bridge handles this transparently
- Auto-detection of async handlers -
inspect.iscoroutinefunction()at the adapter level, no decorator needed - Same middleware chain order - Request Validation → Router Middlewares → Route Middlewares → Response Validation → API Adapter
Out of scope:
- Tracer / X-Ray with
asyncio.gather- known X-Ray SDK issue, tracked separately - Async
resolve()replacing syncresolve()- breaking change,resolve_async()is additive - Async-only validation/serialization - CPU-bound operations, no benefit from async
Alternative solutions
Acknowledgment
- This feature request meets Powertools for AWS Lambda (Python) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Java, TypeScript, and .NET
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsComing soon
Activity
feat(event-handler): add _registered_api_adapter_async() internal bui…
feat(event-handler): add _registered_api_adapter_async() internal bui…
powertools-for-aws-oss-automation commentedon Apr 27, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
github-actions commentedon May 4, 2026
This is now released under 3.29.0 version!