Skip to content

Commit 8a7e705

Browse files
committed
Add typevar
1 parent 31b1dd5 commit 8a7e705

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/oumi/core/async_utils.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import asyncio
22
from multiprocessing.pool import ThreadPool
3-
from typing import Any, Awaitable
3+
from typing import Awaitable, TypeVar
44

5+
T = TypeVar("T")
56

6-
def safe_asyncio_run(main: Awaitable[Any]) -> Any:
7+
8+
def safe_asyncio_run(main: Awaitable[T]) -> T:
79
"""Run a series of Awaitables in a new thread. Blocks until the thread is finished.
810
911
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:
1921
The result of the awaitable.
2022
"""
2123
pool = ThreadPool(processes=1)
22-
return pool.apply(asyncio.run, (main,))
24+
return pool.apply(asyncio.run, (main,)) # type: ignore

0 commit comments

Comments
 (0)