SIGN IN SIGN UP

feat(event-handler): add _registered_api_adapter_async() internal building block (#8157)

* feat(event-handler): add _registered_api_adapter_async() internal building block

- Add async counterpart to _registered_api_adapter()
- Detects if route handler result is a coroutine using inspect.iscoroutine()
- Awaits async handlers; passes sync handlers through unchanged
- _to_response() remains sync (CPU-bound, no async benefit)
- Move import inspect to top-level imports (consistent with file style)
- Nothing calls this in the resolve chain yet — internal building block only

Closes #8135
Part of parent: #3934
Next step: #8137 (public resolve_async()) will wire this in

Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>

* refactor(event-handler): move _registered_api_adapter_async to async_utils.py

Per maintainer feedback on #8157 - function belongs in async_utils.py alongside other async event handler internals (wrap_middleware_async, _run_sync_middleware_in_thread, etc.)

Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>

* test(event-handler): add unit tests for _registered_api_adapter_async()

Tests cover sync handler, async handler, and mixed scenarios as required by issue #8135

Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>

* refactor(event-handler): move _registered_api_adapter_async to async_utils.py

Per maintainer feedback on #8157 - function belongs in async_utils.py
alongside other async event handler internals (wrap_middleware_async,
_run_sync_middleware_in_thread, etc.)

Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>

* fix: small changes

* fix: small changes

* fix: small changes

* fix: small changes

---------

Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
Co-authored-by: Leandro Damascena <lcdama@amazon.pt>
H
hirenkumar-n-dholariya committed
bf411474ea17c219f2bf6658195dc7c733629e2c
Parent: a54b39d
Committed by GitHub <noreply@github.com> on 4/19/2026, 12:03:07 PM