Skip to content

Reply

hololinked.core.eventloop.operations.Reply dataclass

The event loop's answer to one Operation.

Source code in repo/hololinked/hololinked/core/eventloop/operations.py
@dataclass
class Reply:
    """The event loop's answer to one `Operation`."""

    payload: SerializableData
    """the return value, encoded with whatever serializer the objekt is registered against."""
    preserialized_payload: PreserializedData
    """binary part of the return value, if the operation produced one."""
    kind: ReplyKind = ReplyKind.OK
    """how it finished."""

    @property
    def is_error(self) -> bool:
        """Whether the operation raised."""
        return self.kind is ReplyKind.ERROR

    @property
    def timed_out(self) -> bool:
        """Whether the operation never started, or started and did not finish in time."""
        return self.kind in (ReplyKind.INVOKATION_TIMEOUT, ReplyKind.EXECUTION_TIMEOUT)

Attributes

payload instance-attribute

payload: SerializableData

the return value, encoded with whatever serializer the objekt is registered against.

preserialized_payload instance-attribute

preserialized_payload: PreserializedData

binary part of the return value, if the operation produced one.

kind class-attribute instance-attribute

kind: ReplyKind = OK

how it finished.

Functions

__init__

__init__(payload: SerializableData, preserialized_payload: PreserializedData, kind: ReplyKind = ReplyKind.OK) -> None

is_error

is_error() -> bool

Whether the operation raised.

Source code in repo/hololinked/hololinked/core/eventloop/operations.py
@property
def is_error(self) -> bool:
    """Whether the operation raised."""
    return self.kind is ReplyKind.ERROR

timed_out

timed_out() -> bool

Whether the operation never started, or started and did not finish in time.

Source code in repo/hololinked/hololinked/core/eventloop/operations.py
@property
def timed_out(self) -> bool:
    """Whether the operation never started, or started and did not finish in time."""
    return self.kind in (ReplyKind.INVOKATION_TIMEOUT, ReplyKind.EXECUTION_TIMEOUT)

hololinked.core.eventloop.operations.ReplyKind

Bases: StrEnum

How an operation finished, in event loop terms rather than in any protocol's vocabulary.

Source code in repo/hololinked/hololinked/core/eventloop/operations.py
class ReplyKind(StrEnum):
    """How an operation finished, in event loop terms rather than in any protocol's vocabulary."""

    OK = "ok"
    """completed, `payload` carries the return value."""
    ERROR = "error"
    """raised, `payload` carries the formatted exception."""
    EXIT = "exit"
    """the `Thing` was asked to stop; there is no meaningful return value."""
    INVOKATION_TIMEOUT = "invokation_timeout"
    """never started - it was still queued when `invokation_timeout` elapsed."""
    EXECUTION_TIMEOUT = "execution_timeout"
    """started but did not finish within `execution_timeout`. It may still be running."""

Attributes

ERROR class-attribute instance-attribute

ERROR = 'error'

raised, payload carries the formatted exception.

EXECUTION_TIMEOUT class-attribute instance-attribute

EXECUTION_TIMEOUT = 'execution_timeout'

started but did not finish within execution_timeout. It may still be running.

EXIT class-attribute instance-attribute

EXIT = 'exit'

the Thing was asked to stop; there is no meaningful return value.

INVOKATION_TIMEOUT class-attribute instance-attribute

INVOKATION_TIMEOUT = 'invokation_timeout'

never started - it was still queued when invokation_timeout elapsed.

OK class-attribute instance-attribute

OK = 'ok'

completed, payload carries the return value.