PyDrocsid.async_thread ¶
gather_any
async
¶
gather_any(*coroutines: Awaitable[T]) -> tuple[int, T]
Like asyncio.gather, but returns after the first coroutine is done.
Parameters:
-
coroutines
–
the coroutines to run
Returns:
Source code in PyDrocsid/async_thread.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
run_as_task ¶
run_as_task(func: Callable[..., Coroutine[Any, Any, None]]) -> Callable[..., Awaitable[None]]
Decorator for async functions. Instead of calling the decorated function directly, this will create a task for it and return immediately.
Source code in PyDrocsid/async_thread.py
50 51 52 53 54 55 56 57 58 59 60 |
|
semaphore_gather
async
¶
semaphore_gather(n: int, *tasks: Awaitable[T]) -> list[T]
Like asyncio.gather, but limited to n concurrent tasks.
Parameters:
-
n
(
int
) –the maximum number of concurrent tasks
-
tasks
–
the coroutines to run
Returns:
-
list[T]
–a list containing the results of all coroutines
Source code in PyDrocsid/async_thread.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|