chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import asyncio
|
||||
from typing import AsyncGenerator, Callable, Iterator, TypeVar
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
def iterator_to_async(
|
||||
func: Callable[..., Iterator[T]],
|
||||
) -> Callable[..., AsyncGenerator[T, None]]:
|
||||
async def wrapper(*args, **kwargs) -> AsyncGenerator[T, None]:
|
||||
iterator = func(*args, **kwargs)
|
||||
for item in iterator:
|
||||
yield item
|
||||
await asyncio.sleep(0)
|
||||
|
||||
return wrapper
|
||||
Reference in New Issue
Block a user