fix: support non-coroutine awaitables in run_in_loop #101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Support Non-Coroutine Awaitables in run_in_loop
Problem
The
run_in_loop
method previously only properly handled coroutines and futures, but not other awaitable objects like those returned byasyncio.gather()
. This caused issues when trying to run gathered tasks in a background thread loop.#100
Solution
Coroutine[Any, Any, T] | asyncio.Future[T]
to the more generalAwaitable[T]
run_in_loop
to properly handle any awaitable object, including those returned byasyncio.gather()
Testing
run_in_loop
withasyncio.gather()
run_coroutine_sync
withasyncio.gather()
Impact
This change maintains backward compatibility while extending functionality to support more awaitable types, making the library more flexible for various async patterns.