pynenc.invocation.sync_invocation

Module Contents

Classes

SynchronousInvocation

A synchronous implementation of a task invocation.

SynchronousInvocationGroup

A group of synchronous invocations for a specific task.

API

class pynenc.invocation.sync_invocation.SynchronousInvocation(call: pynenc.call.Call[pynenc.types.Params, pynenc.types.Result])[source]

Bases: pynenc.invocation.base_invocation.BaseInvocation[pynenc.types.Params, pynenc.types.Result]

A synchronous implementation of a task invocation.

This class represents an invocation of a task in a synchronous context.

Parameters:

call (Call[Params, Result]) – The specific call instance that this invocation represents.

Danger

Use only for testing purposes where distributed processing is not required.

Initialization

property status: pynenc.invocation.status.InvocationStatus

Get the status of the invocation.

Returns:

The current status of the invocation.

Return type:

InvocationStatus

result() pynenc.types.Result

Execute the task call and return its result.

This method runs the task synchronously and returns the result. It handles retries for retriable exceptions as per the task’s configuration.

Returns:

The result of the task execution.

Return type:

Result

Raises:

Exception – Raised if the task execution results in an unhandled exception.

property num_retries: int

Get the number of retries for the invocation.

Returns:

The number of times the invocation has been retried.

Return type:

int

to_json() str[source]
classmethod from_json(app: pynenc.app.Pynenc, serialized: str) pynenc.invocation.sync_invocation.SynchronousInvocation[source]
class pynenc.invocation.sync_invocation.SynchronousInvocationGroup[source]

Bases: pynenc.invocation.base_invocation.BaseInvocationGroup[pynenc.types.Params, pynenc.types.Result, pynenc.invocation.sync_invocation.SynchronousInvocation]

A group of synchronous invocations for a specific task.

This class extends BaseInvocationGroup to handle groups of SynchronousInvocation instances. It is designed for scenarios where multiple synchronous invocations of a task are managed or processed together.

Parameters:

Danger

Use only for testing purposes where distributed processing is not required.
property results: Iterator[pynenc.types.Result]

An iterator over the results of the invocations in the group.

This property method iterates over the SynchronousInvocation instances in the group, yielding the result of each invocation.

Returns:

An iterator over the results of each invocation in the group.

Return type:

Iterator[Result]