Skip to content

yggdrasil.concurrent.threading.base

base

AsyncJob — abstract awaitable handle for an async operation.

AsyncJob

Bases: ABC, Generic[T]

Abstract handle for an async operation that can be awaited.

Implementors must provide :meth:wait, :attr:is_done, and :meth:result.

is_done abstractmethod property

is_done: bool

True when the job has finished (success or failure).

wait abstractmethod

wait(wait: WaitingConfigArg = None, raise_error: bool = True) -> Optional[T]

Block until the job completes and return its result.

Parameters:

Name Type Description Default
wait WaitingConfigArg

None / True → block indefinitely. False → non-blocking poll; returns None if not yet finished. WaitingConfig or a numeric number of seconds → timed wait.

None
raise_error bool

Re-raise the job's exception when True; return None when False.

True

Returns:

Type Description
Optional[T]

The job's return value, or None on failure / timeout / non-blocking

Optional[T]

miss (when raise_error=False).

Raises:

Type Description
TimeoutError

If a timed wait elapses before the job finishes.

BaseException

Any exception raised by the job (when raise_error=True).

result abstractmethod

result() -> Optional[JobResult[T]]

Return the :class:~yggdrasil.concurrent.job_result.JobResult if done, else None.