|
4 | 4 | import logging |
5 | 5 | import socket |
6 | 6 | from collections.abc import AsyncIterator, Callable, Coroutine |
7 | | -from contextlib import asynccontextmanager |
8 | | -from typing import Any, AsyncContextManager, ParamSpec, TypeVar |
| 7 | +from contextlib import AbstractAsyncContextManager, asynccontextmanager |
| 8 | +from typing import Any, ParamSpec, TypeVar |
9 | 9 |
|
10 | 10 | from common_library.async_tools import cancel_wait_task |
11 | 11 |
|
@@ -211,8 +211,8 @@ def with_limited_concurrency_cm( |
211 | 211 | blocking: bool = True, |
212 | 212 | blocking_timeout: datetime.timedelta | None = DEFAULT_SOCKET_TIMEOUT, |
213 | 213 | ) -> Callable[ |
214 | | - [Callable[P, AsyncContextManager[R]]], |
215 | | - Callable[P, AsyncContextManager[R]], |
| 214 | + [Callable[P, AbstractAsyncContextManager[R]]], |
| 215 | + Callable[P, AbstractAsyncContextManager[R]], |
216 | 216 | ]: |
217 | 217 | """ |
218 | 218 | Decorator to limit concurrent execution of async context managers using a distributed semaphore. |
@@ -247,8 +247,8 @@ async def get_cluster_client(): |
247 | 247 | """ |
248 | 248 |
|
249 | 249 | def _decorator( |
250 | | - cm_func: Callable[P, AsyncContextManager[R]], |
251 | | - ) -> Callable[P, AsyncContextManager[R]]: |
| 250 | + cm_func: Callable[P, AbstractAsyncContextManager[R]], |
| 251 | + ) -> Callable[P, AbstractAsyncContextManager[R]]: |
252 | 252 | @functools.wraps(cm_func) |
253 | 253 | @asynccontextmanager |
254 | 254 | async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> AsyncIterator[R]: |
|
0 commit comments