Ice.InvocationFuture

class Ice.InvocationFuture(asyncInvocationContext: AsyncInvocationContext)

Bases: Future

A Future object representing the result of an AMI (Asynchronous Method Invocation) request.

Instances of InvocationFuture are returned by AMI requests, and applications can either wait for the result of the request to become available, or register a callback which will be invoked when the result becomes available.

Notes

This class provides the same functionality as Ice.Future with the addition of “sent callbacks”; callbacks which are invoked when the request has been sent.

Parameters:

asyncInvocationContext (AsyncInvocationContext)

cancel() bool

Cancels the invocation.

This function invokes Future.cancel() to cancel the underlying future. If the cancellation is successful, the associated invocation is also cancelled.

Cancelling an invocation prevents a queued invocation from being sent. If the invocation has already been sent, cancellation ensures that any reply from the server is ignored.

After cancellation, done() returns True, and attempting to retrieve the result raises an Ice.InvocationCanceledException.

Notes

Cancellation is a local operation with no effect on the server.

Returns:

True if the operation was successfully cancelled, False otherwise.

Return type:

bool

is_sent() bool

Checks if the request has been sent.

Returns:

True if the request has been sent, otherwise False.

Return type:

bool

is_sent_synchronously() bool

Checks if the request was sent synchronously.

Returns:

True if the request was sent synchronously, otherwise False.

Return type:

bool

add_sent_callback(fn: Callable[[bool], None]) None

Attaches a callback function which will be called when the invocation is sent. If the invocation has already been sent, fn is called immediately from the calling thread.

Parameters:

fn (Callable[[bool], None]) – The function to execute when the invocation is sent. It accepts a single boolean argument which is only True if the invocation was sent synchronously.

Return type:

None

sent(timeout: int | float | None = None) bool

Waits until the invocation has been sent.

If the invocation has not been sent, this function will wait up to timeout-many seconds for it to send.

Parameters:

timeout (int | float | None, optional) – Maximum time (in seconds) to wait for the invocation to be sent. If None (the default), this function waits indefinitely.

Returns:

True if the invocation was sent synchronously, otherwise False.

Return type:

bool

Raises:
set_sent(sentSynchronously: bool)
Parameters:

sentSynchronously (bool)