asyncutils._internal.types

Defines interfaces and type aliases used in this module’s stubs to facilitate lightweight type annotations, inline or otherwise.
This is a fake module, and neither it nor any of its symbols exist at runtime.
Thus, export nothing intentionally and prompt type checkers to emit errors when symbols here are used with
from asyncutils._internal.types import *.

Tip

For inline type annotations, wrap the imports in if TYPE_CHECKING: blocks.

Tip

Besides, run from __future__ import annotations on the top of the file for Python 3.13 or below, so that the annotations need not be quoted even prior to the implementation of PEP 563, which introduced deferred annotation evaluation.

Attributes

All

Type of the __all__ attributes of the submodules of asyncutils.

EveryMethodRV

Return type of func.everymethod().

ExcType

The type of exc_typ in :meth:~`object.__exit__` and __aexit__() methods.

Exceptable

The type of objects that may follow an except statement.

ExceptionWrapper

The return type of exceptions.wrap_exc().

Executor

Type of strings representing executors that can be passed to -e/--executor.

HashAlgorithm

Names of algorithms used for calculating checksums. The default is context.MEMORY_MAPPED_IO_MANAGER_DEFAULT_CHECKSUM_ALG. The BLAKE2 family of algorithms, fast and somewhat secure with a low probability of collision, is the default choice.

IntCompatible

Objects accepted by the int constructor.

Middleware

Represents a middleware accepted by EventBus.

NonGroupExc

Exceptions that are not exception groups.

Observer

The type of channels.Observable observers.

OpenFiles

The type of the io.MemoryMappedIOManager.open_files property of io.MemoryMappedIOManager.

OpenRV

The type of the return values of the open(), create() and create_sparsef() methods of MemoryMappedIOManager.

Openable

Anything that can normally be passed to the built-in open() function.

Proxy

A supposed callable object having a FuncWrapper.__wrapped__ or __func__ attribute pointing to the callable it wraps.

RWLockCM

The type of the context managers returned by the reader() and writer() methods of RWLock and subclasses thereof.

Seek

Possible values of the whence parameter for asyncutils.io.MemoryMappedIOManager.seek(), as follows:

SigPatcherArg

The type of a positional argument passed to a signature-patching function in _internal.patch.

SpecificSubscriber

The type of subscribers for channels.EventBus.

Submodule

Type of strings representing asyncutils submodule names.

SupportsIteration

Objects that support (async) iteration.

SupportsRichComparison

Objects implementing one of the operators < and >.

Timer

Type of functions that return the current time under some specification, such as time.monotonic(), time.process_time() and time.perf_counter().

ValidSlice

A slice with start, stop and step being integers or None, representing a slice that typical sequences supporting slicing should accept.

WildcardSubscriber

The type of wildcard subscribers for channels.EventBus.

Wrapper

A function or wrapper of any depth thereof.

Classes

ANCT

Simple async-only version of contextlib.nullcontext that does not depend on contextlib.

AUnzipConsumer

The type of each consumer in the tuple return value of iters.aunzip().

AsyncContextManager

A protocol version of contextlib.AbstractAsyncContextManager with proper overloads.

AsyncLockLike

An object that behaves like an asynchronous lock.

BenchmarkResult

The return type of func.benchmark().

CanClearAndCopy

An iterable that supports clearing and shallow copying.

CanWriteAndFlush

A writable and flushable 'stream'.

DCRV

Protocol for the strict decorator factory overload of util.dualcontextmanager().

DecoratorFactoryRV

The return type of various decorator factories in asyncutils.func, including debounce(), throttle() and debounce().

DualContextManager

Return type of @util.dualcontextmanager. The initialization signature of this class is not documented intentionally.

DumpType

Encapsulates the signature of simple json-dumping functions accepted by argv_to_json() and argstr_to_json().

EventProt

Protocol for event objects.

EveryMethodFT

The type of functions taken by EveryMethodRV.

EveryMethodRVRV

Return type of EveryMethodRV.

EveryRV

The return type of func.every().

FuncProxy

Same as above.

FuncWrapper

Intermediate protocol to build the recursive definition of Wrapper.

FutProt

The barest of protocol for future-like objects such that the class is accepted at runtime by util.done_fut(). Does not require the object to be awaitable, for instance.

FutWrapType

The signature of the functions accepted for the futwrap parameter in convert_to_coro_iter().

GeneratorCoroutine

Objects such as those returned by @types.coroutine-decorated generator functions.

GenericSized

A generic version of typing.Sized.

GetAndPutProtectedQProt

Queues for which both get() and put() are protected by passwords. There is no requirement as to whether they are the same or different.

GetProtectedQProt

Queues for which get() is protected by a password.

IncompleteFut

Since the type system does not allow modelling a type variable to have an upper bound parametrized by another type variable, this is necessary to type the return type of util.done_fut() while losing much type information.

MemoryMappedFile

The type of async memory-mapped files as opened and returned by MemoryMappedIOManager.

PartialInterface

PartialInterfaceMeta

Metaclass for 'partial interfaces', described below.

PathLike

An object that represents a path. Basically os.PathLike, but a Protocol.

PutProtectedQProt

Queues for which put() is protected by a password.

QProt

A base protocol representing password-protected queues.

RWLockRV

The return type of the reader() and writer() methods of RWLock and subclasses thereof.

RaiseType

The type of constants.RAISE.

Reader

io.Reader is not used due to version compatibility issues.

StateSnapshot

Type of snapshots of the current state of a channels.Rendezvous object as returned by its state_snapshot() method.

SubscriptionRV

Return type of the subscribe(), subscribe_nowait() and ntimes() methods of channels.Observable.

SupportsGT

An object that implements the > operator.

SupportsLT

An object that implements the < operator.

SupportsMatMul

Objects that implement matrix multiplication to return an instance of its own type.

SupportsPop

Types with a pop() method.

SupportsPopLeft

Types with a popleft() method.

SupportsSlicing

Protocol for iterables with size, and index and slice access.

ToSyncFromLoopRV

The signature of the return value of util.to_sync_from_loop().

TransientBlockFromLoopRV

The signature of the return value of util.transient_block_from_loop().

WildcardType

Type of channels.EventBus.WILDCARD.

Writer

io.Writer is not used due to version compatibility issues.

Module Contents

class asyncutils._internal.types.ANCT

Simple async-only version of contextlib.nullcontext that does not depend on contextlib.

Note

This does not support the enter_result argument of the original.

async __aenter__() None
async __aexit__(exc_typ: ExcType, exc_val: BaseException, exc_tb: types.TracebackType, /) None
async __aexit__(exc_typ: None, exc_val: None, exc_tb: None, /) None
class asyncutils._internal.types.AUnzipConsumer[T]

The type of each consumer in the tuple return value of iters.aunzip().

__aiter__() Self
async __anext__() T
close() None

Shut down the underlying queue, such that this consumer no longer receives the values at its position.

class asyncutils._internal.types.AsyncContextManager[T]

Bases: Protocol

A protocol version of contextlib.AbstractAsyncContextManager with proper overloads.

async __aenter__() T
async __aexit__(exc_typ: ExcType, exc_val: BaseException, exc_tb: types.TracebackType, /) bool | None
async __aexit__(exc_typ: None, exc_val: None, exc_tb: None, /) bool | None
class asyncutils._internal.types.AsyncLockLike[T]

Bases: AsyncContextManager[T], Protocol

An object that behaves like an asynchronous lock.

async acquire() bool | None
locked() bool
release() collections.abc.Awaitable[None] | None
class asyncutils._internal.types.BenchmarkResult

Bases: NamedTuple

The return type of func.benchmark().

avg: float

br.avg == br.total/br.iterations.

iterations: int

The times constructor parameter.

max: float

The maximum execution time among all non-warmup calls.

min: float

The minimum execution time among all non-warmup calls.

total: float

The total execution time.

class asyncutils._internal.types.CanClearAndCopy[T]

Bases: Protocol

An iterable that supports clearing and shallow copying.

__iter__() collections.abc.Iterator[T]
clear() None
copy() Self
class asyncutils._internal.types.CanWriteAndFlush[T]

Bases: Protocol

A writable and flushable ‘stream’.

flush() None
write(s: T, /) int | None
class asyncutils._internal.types.DCRV

Bases: Protocol

Protocol for the strict decorator factory overload of util.dualcontextmanager().

__call__[T, **P](
gfunc: collections.abc.Callable[P, collections.abc.Iterable[T]],
/,
) collections.abc.Callable[P, contextlib.AbstractContextManager[T]]
__call__(
agfunc: collections.abc.Callable[P, collections.abc.AsyncIterable[T]],
/,
) collections.abc.Callable[P, contextlib.AbstractAsyncContextManager[T]]
class asyncutils._internal.types.DecoratorFactoryRV

Bases: Protocol

The return type of various decorator factories in asyncutils.func, including debounce(), throttle() and debounce().

__call__[T, **P](
f: collections.abc.Callable[P, collections.abc.Awaitable[T]],
/,
) collections.abc.Callable[P, types.CoroutineType[Any, Any, T]]
class asyncutils._internal.types.DualContextManager[T]

Bases: contextlib.AbstractContextManager[T, bool], contextlib.AbstractAsyncContextManager[T, bool], Protocol

Return type of @util.dualcontextmanager. The initialization signature of this class is not documented intentionally.

class asyncutils._internal.types.DumpType

Bases: Protocol

Encapsulates the signature of simple json-dumping functions accepted by argv_to_json() and argstr_to_json().

__call__(dct: dict[str, Any], file: io.TextIOWrapper[io._WrappedBuffer], /) None
class asyncutils._internal.types.EventProt

Bases: Protocol

Protocol for event objects.

clear() None

Clear the event, causing future waiters to block until it is set again.

is_set() bool

Return whether the event is set.

set() None

Set the event, allowing any waiters to proceed.

async wait() Any

Asynchronously wait until the event is set.

class asyncutils._internal.types.EveryMethodFT[T, R]

Bases: Protocol

The type of functions taken by EveryMethodRV.

__call__(self_: T, /, *a: object, **k: object) collections.abc.Awaitable[R]
class asyncutils._internal.types.EveryMethodRVRV[T, R]

Bases: Protocol

Return type of EveryMethodRV.

async __call__(self_: T, /, *a: object, **k: object) R | None
class asyncutils._internal.types.EveryRV[T]

Bases: Protocol

The return type of func.every().

__call__[**P](
f: collections.abc.Callable[P, collections.abc.Awaitable[T]],
/,
) collections.abc.Callable[P, types.CoroutineType[Any, Any, T | None]]
class asyncutils._internal.types.FuncProxy[W]

Bases: Protocol

Same as above.

property __func__: W
class asyncutils._internal.types.FuncWrapper[W]

Bases: Protocol

Intermediate protocol to build the recursive definition of Wrapper.

property __wrapped__: W
class asyncutils._internal.types.FutProt[T]

Bases: Protocol

The barest of protocol for future-like objects such that the class is accepted at runtime by util.done_fut(). Does not require the object to be awaitable, for instance.

exception() BaseException | None

Return the exception set on the future if any.

result() T

Return the result or raise the exception set on the future.

set_exception(exc: BaseException, /) None

Set an exception on the future, causing it to be raised by any waiters.

set_result(result: T, /) None

Set a result on the future, making it available to any waiters.

class asyncutils._internal.types.FutWrapType

Bases: Protocol

The signature of the functions accepted for the futwrap parameter in convert_to_coro_iter().

__call__[T](
future: asyncio.Future[T] | concurrent.futures.Future[T],
*,
loop: asyncio.AbstractEventLoop | None,
) asyncio.Future[T]
class asyncutils._internal.types.GeneratorCoroutine[Y, S, R]

Bases: collections.abc.Generator[Y, S, R], collections.abc.Coroutine[Y, S, R]

Objects such as those returned by @types.coroutine-decorated generator functions.

__await__() collections.abc.Generator[Any, None, R]
close() R | None

Raise GeneratorExit inside generator.

send(val: S, /) Y

Send a value into the generator. Return next yielded value or raise StopIteration.

throw(typ: ExcType, val: object = ..., tb: types.TracebackType | None = ..., /) Y
throw(exc: BaseException, val: None = ..., tb: types.TracebackType | None = ..., /) Y

Raise an exception in the generator. Return next yielded value or raise StopIteration.

property __name__: str
property __qualname__: str
property gi_code: types.CodeType
property gi_frame: types.FrameType | None
property gi_running: bool
property gi_suspended: bool
property gi_yieldfrom: collections.abc.Iterator[Y] | None
class asyncutils._internal.types.GenericSized[T]

Bases: Protocol

A generic version of typing.Sized.

__iter__() collections.abc.Iterator[T]
__len__() int
class asyncutils._internal.types.GetAndPutProtectedQProt[R, V, T]

Bases: GetProtectedQProt[R, T], PutProtectedQProt[V, T], QProt[R, V, T], Protocol

Queues for which both get() and put() are protected by passwords. There is no requirement as to whether they are the same or different.

class asyncutils._internal.types.GetProtectedQProt[R, T]

Bases: QProt[R, Any, T], Protocol

Queues for which get() is protected by a password.

async get(pwd: R) T

Remove and return an item from the password-protected queue, if the password provided was correct; raise exceptions.WrongPassword otherwise. If the queue is empty, wait until an item is available.

get_nowait(pwd: R) T

Remove and return an item from the password-protected queue, if the password provided was correct; raise exceptions.WrongPassword otherwise. If the queue is empty, raise QueueEmpty.

class asyncutils._internal.types.IncompleteFut[T](*a: object, **k: object)

Bases: FutProt[T], PartialInterface

Since the type system does not allow modelling a type variable to have an upper bound parametrized by another type variable, this is necessary to type the return type of util.done_fut() while losing much type information.

class asyncutils._internal.types.MemoryMappedFile

Bases: asyncutils.mixins.LoopContextMixin

The type of async memory-mapped files as opened and returned by MemoryMappedIOManager.

__aiter__() collections.abc.AsyncGenerator[bytes]

Return an asynchronous iterator over the lines of the file.

async __cleanup__() None
__iter__() collections.abc.Iterator[bytes]

Return an iterator over the lines of the file.

async __setup__() None
async aclose() None

Close the memory-mapped file and the underlying file concurrently in async. It is safe to call this method multiple times, but no other methods should be called after closing.

close() None

Close the memory-mapped file and the underlying file. It is safe to call this method multiple times, but no other methods should be called after closing.

async compact() int

Reduce the size of the file by stripping all contiguous null bytes at the end, and return the number of bytes removed.

async compare(other: Self, /, size: int = ..., offset_self: int = ..., offset_other: int = ...) bool

Compare a range of bytes in this file with a range in another file.

async copy_range(src_offset: int, dest_offset: int, size: int) bool

Copy a range of bytes from one location to another in the file.

async delete(offset: int, size: int) None

Delete a range of bytes from the file.

fileno() int

The file descriptor of the underlying file.

async fill(pattern: bytes, offset: int = ..., count: int = ...) None

Fill a range of the file with a repeating pattern of bytes.

find(sub: bytes, start: int | None = ..., end: int | None = ...) int

Return the lowest index in the file where the bytes sub is found, such that sub is contained in the slice file[start:end]. Return -1 if sub is not found.

async flush(offset: int = ..., size: int | None = ..., /) None

Flush the file, or a portion of it if offset and size are specified. If size is None, flush until the end of the file.

async hamming_dist(other: Self, /, size: int = ..., offset_self: int = ..., offset_other: int = ...) int

Calculate the Hamming distance in bits between a range of bytes in this file and a range in another file.

async hamming_dist_bytes(other: Self, /, size: int = ..., offset_self: int = ..., offset_other: int = ...) int

Calculate the Hamming distance in bytes between a range of bytes in this file and a range in another file.

async insert(data: bytes, offset: int) None

Insert data into the file at the specified offset.

isatty() bool

Return whether the file is connected to a TTY device.

madvise(option: int, start: int = ..., length: int | None = ...) None

Advise the kernel about how to handle the memory map by making the madvise system call.

async move(dest: int, src: int, count: int) None

Move count bytes of data within the file starting from src to dest.

async read(offset: int = ..., size: int = ...) bytes

Read size bytes from the file at offset. A negative size reads until the end of the file.

read_byte() int

Read one byte from the file at the current file pointer, advance the pointer and return the byte as an integer >=0, <256.

async read_str(offset: int = ..., size: int = ..., encoding: str = ..., errors: str = ...) str

Version of read() returning a string instead, decoded with the specified encoding and errors.

async read_until(delim: bytes, offset: int = ..., maxsize: int = ...) tuple[bytes, int]

Read bytes from the file until the delimiter is found or the maximum size is reached.

readable() Literal[True]

Implemented to always return True to satisfy the file interface.

async readline(offset: int = ..., size: int | None = ..., incl_newline: bool = ...) bytes

Read a line from the file at offset, up to a maximum of size bytes if size is not None, and return it, optionally including the newline character.

async readlines(hint: int = ...) list[bytes]

Read lines from the file until the total size of the lines read reaches or exceeds hint if hint is non-negative, and return a list of the lines read.

async replace(old: bytes, new: bytes, offset: int = ..., count: int = ...) int

Replace occurrences of a pattern in the file with a new pattern.

resize(newsize: int) None

Resize the file to newsize bytes. If the file is extended, the added bytes are zero-filled.

rfind(sub: bytes, start: int | None = ..., end: int | None = ...) int

Return the highest index in the file where the bytes sub is found, such that sub is contained in the slice file[start:end]. Return -1 if sub is not found.

async search(pattern: bytes, offset: int = ..., max_results: int = ...) list[int]

Return a list of the offsets of the first max_results occurrences of pattern in the file starting from offset.

search_lazy(pattern: bytes, offset: int = ...) collections.abc.AsyncGenerator[int]

Search for a pattern in the file starting from the specified offset, yielding the offsets of each occurrence found as they are found.

search_lazy_nonoverlapping(pattern: bytes, offset: int = ...) collections.abc.AsyncGenerator[int]

The above, but ensure the offsets returned do not overlap using a greedy approach.

async search_nonoverlapping(pattern: bytes, offset: int = ..., max_results: int = ...) list[int]

The above, but ensure the offsets returned do not overlap. Greedy.

async seek(pos: int, whence: Seek = ...) None

Move the file pointer to pos according to whence.

seekable() Literal[True]

Implemented to always return True to satisfy the file interface.

size() int

Return the size of the file in bytes.

async smart_write(data: str, offset: int = ..., encoding: str = ..., errors: str = ...) None
async smart_write(data: bytes, offset: int = ...) None

Write data to the file at the specified offset, automatically encoding strings.

sync() None

Force the file to be written to disk, in addition to flushing the memory map.

tell() int

Return the current file pointer position.

writable() Literal[True]

Implemented to always return True to satisfy the file interface.

async write(data: bytes, offset: int = ...) None

Write data into the file at offset.

write_byte(b: int, /) None

Write a byte to the file at the current file pointer and advance the pointer.

async write_str(text: str, offset: int = ..., encoding: str = ..., errors: str = ...) None

Write a string to the file at the specified offset, encoded with the specified encoding and errors.

async writelines(lines: collections.abc.Iterable[bytes], /, *, sep: bytes = ..., minimize_writes: bool = ...) None

Write each line in lines, followed by sep, into the file. If minimize_writes is True (default context.MEMORY_MAPPED_IO_MANAGER_DEFAULT_MINIMIZE_WRITES), write all the lines in one call.

property closed: bool

Whether the file and memory map have been closed.

property open_files: OpenFiles

Return a dictionary mapping tuples of the form (file, mode) to the file objects underlying this memory-mapped file.

class asyncutils._internal.types.PartialInterface(*a: object, **k: object)
Base class for partial interfaces.
If it is only known that a class implements an interface, static code analysis tools might emit diagnostics on unrecognized attributes that
may actually exist on the object or class.
This is a simplistic fix that asks type checkers to assume those attributes always exist and make no attempt to infer their types.
__getattr__(name: str, /) Any
class asyncutils._internal.types.PartialInterfaceMeta

Bases: type

Metaclass for ‘partial interfaces’, described below.

__getattr__(name: str, /) Any
class asyncutils._internal.types.PathLike[T]

Bases: Protocol

An object that represents a path. Basically os.PathLike, but a Protocol.

__fspath__() T
class asyncutils._internal.types.PutProtectedQProt[V, T]

Bases: QProt[Any, V, T], Protocol

Queues for which put() is protected by a password.

async put(item: T, pwd: V) None

Put an item into the password-protected queue, if the password provided was correct; raise exceptions.WrongPassword otherwise. If the queue is full, wait until a free slot is available.

put_nowait(item: T, pwd: V) None

Put an item into the password-protected queue, if the password provided was correct; raise exceptions.WrongPassword otherwise. If the queue is full, raise QueueFull.

class asyncutils._internal.types.QProt[R, V, T]

Bases: Protocol

A base protocol representing password-protected queues.

cancel_extend(msg: object = ...) bool
Cancel the currently running task to put in the initial items to the queue asynchronously, optionally with a message, which will
be the argument for the CancelledError seen by the extender if any.
Return False if the task is already done or cancelled, or there was no task to begin with.
change_get_password(old_pwd: R, new_pwd: R) bool

Attempt to change the get password of the password-protected queue to new_pwd given old_pwd and return success. Always fails if the queue does not protect gets or is empty and has been shut down.

change_put_password(old_pwd: V, new_pwd: V) bool

Attempt to change the put password of the password-protected queue to new_pwd given old_pwd and return success. Always fails if the queue does not protect puts or has been shut down.

empty() bool

Check if the queue is empty.

full() bool

Check if the queue is full.

async get() T

Asynchronously get an item from the queue; if the queue is empty, wait until an item is available.

get_nowait() T

Get an item from the queue immediately; raise QueueEmpty if impossible.

async join() None

Wait until task_done() has been called for each item put into the queue.

async put(item: T) None

Asynchronously put an item into the queue; if the queue is full, wait until a free slot is available.

put_nowait(item: T) None

Put an item into the queue immediately; raise QueueFull if impossible.

qsize() int

Number of items in the queue.

shutdown(immediate: bool = ...) None

Shut down the queue. If immediate is True, pending gets raise immediately even if the queue is not empty.

task_done() None

Mark the completion of a task gotten from the queue to join().

exc: type[asyncutils.exceptions.ForbiddenOperation]

Convenience alias for ForbiddenOperation.

property maxsize: int

Maximum number of items allowed in the queue at any moment.

class asyncutils._internal.types.RWLockRV[T, **P]

Bases: Protocol

The return type of the reader() and writer() methods of RWLock and subclasses thereof.

__call__(*a: P, **k: P) types.CoroutineType[Any, Any, T]
reader(f: collections.abc.Callable[P, collections.abc.Awaitable[T]], /) Self

Mark another function as a reader and return an object with reader() and writer() methods.

writer(f: collections.abc.Callable[P, collections.abc.Awaitable[T]], /) Self

Mark another function as a writer and return an object with reader() and writer() methods.

class asyncutils._internal.types.RaiseType

Bases: asyncutils.constants.sentinel_base

The type of constants.RAISE.

__reduce__() str

It is accessible in the top level of the constants namespace.

is_(other: object, /) TypeGuard[Self]

Allows for effective type narrowing.

class asyncutils._internal.types.Reader[T]

Bases: Protocol

io.Reader is not used due to version compatibility issues.

read(size: int = ..., /) T
class asyncutils._internal.types.StateSnapshot

Bases: NamedTuple

Type of snapshots of the current state of a channels.Rendezvous object as returned by its state_snapshot() method.

idle: bool

ss.idle == (ss.num_getters == ss.num_putters == 0)

num_getters: int

Current number of slots waiting for values.

num_ops: int

ss.num_ops == ss.num_getters+ss.num_putters

num_putters: int

Current number of values waiting for slots.

class asyncutils._internal.types.SubscriptionRV

Bases: Protocol

Return type of the subscribe(), subscribe_nowait() and ntimes() methods of channels.Observable.

__call__(strict: bool = ...) None
class asyncutils._internal.types.SupportsGT

Bases: Protocol

An object that implements the > operator.

__gt__(other: Self, /) bool
class asyncutils._internal.types.SupportsLT

Bases: Protocol

An object that implements the < operator.

__lt__(other: Self, /) bool
class asyncutils._internal.types.SupportsMatMul

Bases: Protocol

Objects that implement matrix multiplication to return an instance of its own type.

__matmul__(other: Self, /) Self
class asyncutils._internal.types.SupportsPop[T]

Bases: Protocol

Types with a pop() method.

pop() T
class asyncutils._internal.types.SupportsPopLeft[T]

Bases: Protocol

Types with a popleft() method.

popleft() T
class asyncutils._internal.types.SupportsSlicing[T]

Bases: GenericSized[T], Protocol

Protocol for iterables with size, and index and slice access.

__getitem__(idx: ValidSlice, /) Self
__getitem__(idx: SupportsIndex, /) T
__len__() int
__reversed__() collections.abc.Iterator[T]

The requirements for this protocol makes children automatically reversible.

class asyncutils._internal.types.ToSyncFromLoopRV

Bases: Protocol

The signature of the return value of util.to_sync_from_loop().

__call__[R, **P](
f: collections.abc.Callable[P, collections.abc.Awaitable[R]],
/,
timeout: float | None = ...,
) collections.abc.Callable[P, R]
class asyncutils._internal.types.TransientBlockFromLoopRV

Bases: Protocol

The signature of the return value of util.transient_block_from_loop().

__call__[T, **P](f: collections.abc.Callable[P, T], /, *a: P, **k: P) asyncio.Future[T]
class asyncutils._internal.types.WildcardType

Type of channels.EventBus.WILDCARD.

__bool__() Literal[False]
class asyncutils._internal.types.Writer[T]

Bases: Protocol

io.Writer is not used due to version compatibility issues.

write(data: T, /) int
type asyncutils._internal.types.All = tuple[str, ...]

Type of the __all__ attributes of the submodules of asyncutils.

type asyncutils._internal.types.EveryMethodRV = Callable[[EveryMethodFT[T, R]], EveryMethodRVRV[T, R]]

Return type of func.everymethod().

type asyncutils._internal.types.ExcType = type[BaseException]

The type of exc_typ in :meth:~`object.__exit__` and __aexit__() methods.

type asyncutils._internal.types.Exceptable = ExcType | tuple[ExcType, ...]

The type of objects that may follow an except statement.

asyncutils._internal.types.ExceptionWrapper

The return type of exceptions.wrap_exc().

type asyncutils._internal.types.Executor = Literal['thread', 'process', 'interpreter', 'loky', 'loky_noreuse', 'dask', 'ipython', 'elib_flux_cluster', 'elib_flux_job', 'elib_slurm_cluster', 'elib_slurm_job', 'elib_single_node', 'pebble_thread', 'pebble_process', 'deadpool']

Type of strings representing executors that can be passed to -e/–executor.

type asyncutils._internal.types.HashAlgorithm = Literal['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'blake2b', 'blake2s', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'shake_128', 'shake_256']

Names of algorithms used for calculating checksums. The default is context.MEMORY_MAPPED_IO_MANAGER_DEFAULT_CHECKSUM_ALG. The BLAKE2 family of algorithms, fast and somewhat secure with a low probability of collision, is the default choice.

type asyncutils._internal.types.IntCompatible = str | SupportsInt | SupportsIndex | Buffer

Objects accepted by the int constructor.

type asyncutils._internal.types.Middleware = Callable[[str, Any], Any]

Represents a middleware accepted by EventBus.

type asyncutils._internal.types.NonGroupExc = Intersection[BaseException, Not[BaseExceptionGroup]]

Exceptions that are not exception groups.

type asyncutils._internal.types.Observer = Callable[Concatenate[Any, P], Awaitable[Any]]

The type of channels.Observable observers.

type asyncutils._internal.types.OpenFiles = dict[tuple[TextIOWrapper[_WrappedBuffer], Literal['r+b', 'w+b', 'x+b']], MemoryMappedFile]

The type of the io.MemoryMappedIOManager.open_files property of io.MemoryMappedIOManager.

type asyncutils._internal.types.OpenRV = AbstractContextManager[MemoryMappedFile, None]

The type of the return values of the open(), create() and create_sparsef() methods of MemoryMappedIOManager.

type asyncutils._internal.types.Openable = int | str | bytes | PathLike[str] | PathLike[bytes]

Anything that can normally be passed to the built-in open() function.

type asyncutils._internal.types.Proxy = FuncProxy[W] | FuncWrapper[W]

A supposed callable object having a FuncWrapper.__wrapped__ or __func__ attribute pointing to the callable it wraps.

type asyncutils._internal.types.RWLockCM = AbstractAsyncContextManager[None, None]

The type of the context managers returned by the reader() and writer() methods of RWLock and subclasses thereof.

type asyncutils._internal.types.Seek = Literal[0, 1, 2]

Possible values of the whence parameter for asyncutils.io.MemoryMappedIOManager.seek(), as follows:

  • 0: SEEK_SET

  • 1: SEEK_CUR

  • 2: SEEK_END

type asyncutils._internal.types.SigPatcherArg = tuple[Wrapper, str]

The type of a positional argument passed to a signature-patching function in _internal.patch.

type asyncutils._internal.types.SpecificSubscriber = Callable[[Any], Awaitable[object]]

The type of subscribers for channels.EventBus.

type asyncutils._internal.types.Submodule = Literal['altlocks', 'base', 'buckets', 'channels', 'cli', 'compete', 'config', 'console', 'constants', 'context', 'events', 'exceptions', 'func', 'futures', 'io', 'iterclasses', 'iters', 'locks', 'locksmiths', 'misc', 'mixins', 'networking', 'pools', 'processors', 'properties', 'queues', 'rwlocks', 'signals', 'tools', 'util', 'version']

Type of strings representing asyncutils submodule names.

type asyncutils._internal.types.SupportsIteration = Iterable[T] | AsyncIterable[T]

Objects that support (async) iteration.

type asyncutils._internal.types.SupportsRichComparison = SupportsLT | SupportsGT

Objects implementing one of the operators < and >.

type asyncutils._internal.types.Timer = Callable[[], float]

Type of functions that return the current time under some specification, such as time.monotonic(), time.process_time() and time.perf_counter().

type asyncutils._internal.types.ValidSlice = slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None]

A slice with start, stop and step being integers or None, representing a slice that typical sequences supporting slicing should accept.

type asyncutils._internal.types.WildcardSubscriber = Callable[[str, Any], Awaitable[object]]

The type of wildcard subscribers for channels.EventBus.

type asyncutils._internal.types.Wrapper = FunctionType | Proxy[FunctionType | Wrapper]

A function or wrapper of any depth thereof.