Beispiel #1
0
 def exception(self):
     """Calls :meth:`grpc.Future.exception` on attr:`future`."""
     # GRPC will actually raise FutureCancelledError.
     # We'll translate that to our own Cancelled exception and *return* it,
     # which is far more polite for a method that *returns exceptions*.
     try:
         return self.future.exception()
     except grpc.FutureCancelledError:
         return exceptions.Cancelled()
    def cancel(self):
        """Attempt to cancel the task for this future.

        If the task has already completed, this call will do nothing.
        Otherwise, this will attempt to cancel whatever task this future is
        waiting on. There is no specific guarantee the underlying task will be
        cancelled.
        """
        if not self.done():
            self.set_exception(exceptions.Cancelled())