Use case
HttpResolverLocal contains async middleware coordination logic (threading bridge between sync middlewares and async context) that we need to reuse in the main resolvers for async support. Currently this logic is buried as private methods in HttpResolverLocal and can't be shared.
Solution/User Experience
- Create
aws_lambda_powertools/event_handler/middlewares/async_utils.py
- Extract
_wrap_middleware_async() threading coordination logic (the asyncio.Event + threading.Event bridge that allows sync middlewares to work in async context)
- Refactor
HttpResolverLocal to use the extracted utilities instead of its own private methods
- All existing tests pass, zero behavior change
This is a refactor with no new functionality. No tests changes to make sure this won't break.
Alternative solutions
Acknowledgment
Use case
HttpResolverLocalcontains async middleware coordination logic (threading bridge between sync middlewares and async context) that we need to reuse in the main resolvers for async support. Currently this logic is buried as private methods inHttpResolverLocaland can't be shared.Solution/User Experience
aws_lambda_powertools/event_handler/middlewares/async_utils.py_wrap_middleware_async()threading coordination logic (theasyncio.Event+threading.Eventbridge that allows sync middlewares to work in async context)HttpResolverLocalto use the extracted utilities instead of its own private methodsThis is a refactor with no new functionality. No tests changes to make sure this won't break.
Alternative solutions
Acknowledgment