We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 31b1dd5 commit 8a7e705Copy full SHA for 8a7e705
src/oumi/core/async_utils.py
@@ -1,9 +1,11 @@
1
import asyncio
2
from multiprocessing.pool import ThreadPool
3
-from typing import Any, Awaitable
+from typing import Awaitable, TypeVar
4
5
+T = TypeVar("T")
6
-def safe_asyncio_run(main: Awaitable[Any]) -> Any:
7
+
8
+def safe_asyncio_run(main: Awaitable[T]) -> T:
9
"""Run a series of Awaitables in a new thread. Blocks until the thread is finished.
10
11
This circumvents the issue of running async functions in the main thread when
@@ -19,4 +21,4 @@ def safe_asyncio_run(main: Awaitable[Any]) -> Any:
19
21
The result of the awaitable.
20
22
"""
23
pool = ThreadPool(processes=1)
- return pool.apply(asyncio.run, (main,))
24
+ return pool.apply(asyncio.run, (main,)) # type: ignore
0 commit comments