Ice.InvocationFuture¶
- class Ice.InvocationFuture(asyncInvocationContext: AsyncInvocationContext)¶
Bases:
FutureA Future object representing the result of an AMI (Asynchronous Method Invocation) request.
Instances of
InvocationFutureare 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.Futurewith 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()returnsTrue, and attempting to retrieve the result raises anIce.InvocationCanceledException.Notes
Cancellation is a local operation with no effect on the server.
- Returns:
Trueif the operation was successfully cancelled,Falseotherwise.- Return type:
- is_sent() bool¶
Checks if the request has been sent.
- Returns:
Trueif the request has been sent, otherwiseFalse.- Return type:
- is_sent_synchronously() bool¶
Checks if the request was sent synchronously.
- Returns:
Trueif the request was sent synchronously, otherwiseFalse.- Return type:
- 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,
fnis 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
Trueif 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:
Trueif the invocation was sent synchronously, otherwiseFalse.- Return type:
- Raises:
TimeoutException – If the invocation was not sent within the specified timeout.
InvocationCanceledException – If the invocation was cancelled before it was sent.