Futures#
-
class
google.cloud.pubsub_v1.publisher.futures.
Future
(completed=None)[source]# This future object is returned from asychronous Pub/Sub publishing calls.
Calling
result()
will resolve the future by returning the message ID, unless an error occurs.-
add_done_callback
(callback)[source]# Attach the provided callable to the future.
The provided function is called, with this future as its only argument, when the future finishes running.
- Parameters
callback (Callable) – The function to call.
- Returns
None
-
cancel
()[source]# Actions in Pub/Sub generally may not be canceled.
This method always returns False.
-
cancelled
()[source]# Actions in Pub/Sub generally may not be canceled.
This method always returns False.
-
done
()[source]# Return True the future is done, False otherwise.
This still returns True in failure cases; checking
result()
orexception()
is the canonical way to assess success or failure.
-
exception
(timeout=None)[source]# Return the exception raised by the call, if any.
- Parameters
timeout (Union[int, float]) – The number of seconds before this call times out and raises TimeoutError.
- Raises
concurrent.futures.TimeoutError – If the request times out.
- Returns
The exception raised by the call, if any.
- Return type
-
result
(timeout=None)[source]# Return the message ID or raise an exception.
This blocks until the message has been published successfully and returns the message ID unless an exception is raised.
- Parameters
timeout (Union[int, float]) – The number of seconds before this call times out and raises TimeoutError.
- Returns
The message ID.
- Return type
- Raises
concurrent.futures.TimeoutError – If the request times out.
Exception – For undefined exceptions in the underlying call execution.
-
running
()[source]# Actions in Pub/Sub generally may not be canceled.
- Returns
True
if this method has not yet completed, orFalse
if it has completed.
- Return type
-