asyncutils.futures¶
Various implementations of future and task classes, eager, time-aware and supporting asynchronous and no-argument callbacks.
Classes¶
A subclass of |
|
The above, but a task. |
|
A subclass of |
|
A subclass of |
|
A subclass of |
|
A subclass of |
|
A subclass of |
|
A subclass of |
|
A subclass of |
|
A subclass of |
Module Contents¶
- class asyncutils.futures.AsyncCallbacksFuture[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
asyncio.Future[T]A subclass of
Futurethat supports calling asynchronous callbacks and callbacks with no arguments on completion.Note
To hook into the callbacks mechanism, subclassing the C-accelerated implementation of
Futurein_asynciois impossible; i.e., using many of them, for example when implementing a queue, may be slower.- add_async_callback(
- fn: collections.abc.Callable[[Self], collections.abc.Coroutine[Any, Any, Any]],
- /,
- *,
- context: contextvars.Context | None = ...,
Add an asynchronous callback to be called when the future is done. The callback will be passed the future as an argument.
- add_noargs_async_callback(
- fn: collections.abc.Callable[[], collections.abc.Coroutine[Any, Any, Any]],
- /,
- *,
- context: contextvars.Context | None = ...,
Add an asynchronous callback with no arguments to be called when the future is done.
- add_noargs_callback(fn: collections.abc.Callable[[], object], /, *, context: contextvars.Context | None = ...) None[source]¶
Add a callback with no arguments to be called when the future is done.
- remove_async_callback(fn: collections.abc.Callable[[Self], collections.abc.Coroutine[Any, Any, Any]], /) int¶
Remove an asynchronous callback. Returns the number of callbacks removed.
- remove_noargs_async_callback(fn: collections.abc.Callable[[], collections.abc.Coroutine[Any, Any, Any]], /) int¶
Remove an asynchronous callback with no arguments. Returns the number of callbacks removed.
- remove_noargs_callback(fn: collections.abc.Callable[[], object], /) int¶
Remove a callback with no arguments. Returns the number of callbacks removed.
- class asyncutils.futures.AsyncCallbacksTask[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
asyncio.Task[T],AsyncCallbacksFuture[T]The above, but a task.
- class asyncutils.futures.EagerAsyncCallbacksFuture[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
AsyncCallbacksFuture[T]A subclass of
AsyncCallbacksFuturethat uses an eager task factory.
- class asyncutils.futures.EagerAsyncCallbacksTask[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
AsyncCallbacksTask[T],EagerAsyncCallbacksFuture[T]A subclass of
AsyncCallbacksTaskthat uses an eager task factory.
- class asyncutils.futures.EagerTimeAwareAsyncCallbacksFuture[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
TimeAwareAsyncCallbacksFuture[T],EagerAsyncCallbacksFuture[T]A subclass of
TimeAwareAsyncCallbacksFuturethat uses an eager task factory.
- class asyncutils.futures.EagerTimeAwareAsyncCallbacksTask[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
TimeAwareAsyncCallbacksTask[T],EagerAsyncCallbacksTask[T]A subclass of
TimeAwareAsyncCallbacksTaskthat uses an eager task factory.
- class asyncutils.futures.TimeAwareAsyncCallbacksFuture[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
TimeAwareFuture[T],AsyncCallbacksFuture[T]A subclass of
AsyncCallbacksFuturethat can be compared to otherTimeAwareAsyncCallbacksFuture’s based on the time they were created.
- class asyncutils.futures.TimeAwareAsyncCallbacksTask[T](*, loop: asyncio.AbstractEventLoop | None = ...)[source]¶
Bases:
TimeAwareTask[T],AsyncCallbacksTask[T]A subclass of
AsyncCallbacksTaskthat can be compared to otherTimeAwareAsyncCallbacksTask’s based on the time they were created.
- class asyncutils.futures.TimeAwareFuture[T][source]¶
Bases:
asyncio.Future[T]A subclass of
Futurethat can be compared to otherTimeAwareFuture’s based on the time they were created.
- class asyncutils.futures.TimeAwareTask[T][source]¶
Bases:
asyncio.Task[T]A subclass of
Taskthat can be compared to otherTimeAwareTask’s based on the time they were created.