Ice.InvocationFuture¶
- class Ice.InvocationFuture(asyncInvocationContext: AsyncInvocationContext)¶
Bases:
FutureA Future object representing the result of an AMI (Asynchronous Method Invocation) request.
InvocationFuture objects are returned by AMI requests. The application can use an InvocationFuture object to wait for the result of the AMI request or register a callback that will be invoked when the result becomes available.
This class provides the same functionality as Future, with the addition of “sent callbacks,” which are invoked when the request is sent.
- Parameters:
asyncInvocationContext (AsyncInvocationContext)
- add_sent_callback(fn: Callable[[bool], None]) None¶
Attach a callback to be executed when the invocation is sent.
The callback fn is called with a boolean argument, indicating whether the invocation was sent synchronously.
If the future has already been sent, fn is called immediately from the calling thread.
- Parameters:
fn (Callable) – The function to execute when the invocation is sent.
- Return type:
None
- cancel() bool¶
Cancels the invocation.
This method 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.
Cancellation is a local operation with no effect on the server.
After cancellation,
done()returnsTrue, and attempting to retrieve the result raises anIce.InvocationCanceledException.- Returns:
Trueif the operation was successfully cancelled,Falseotherwise.- Return type:
- is_sent() bool¶
Check if the request has been sent.
- Returns:
True if the request has been sent, otherwise False.
- Return type:
- is_sent_synchronously() bool¶
Check if the request was sent synchronously.
- Returns:
True if the request was sent synchronously, otherwise False.
- Return type:
- sent(timeout: int | float | None = None) bool¶
Wait for the operation to be sent.
This method waits up to timeout seconds for the operation to be sent and then returns whether it was sent synchronously.
If the operation has not been sent within the specified time, a TimeoutException is raised. If the future was cancelled before being sent, an InvocationCanceledException is raised.
- Parameters:
timeout (int | float, optional) – Maximum time (in seconds) to wait for the operation to be sent. If None, the method waits indefinitely.
- Returns:
True if the operation was sent synchronously, otherwise False.
- Return type:
- Raises:
TimeoutException – If the operation was not sent within the specified timeout.
InvocationCanceledException – If the operation was cancelled before it was sent.