Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/api_core/future/base.py: 70%
30 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:45 +0000
1# Copyright 2017, Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15"""Abstract and helper bases for Future implementations."""
17import abc
20class Future(object, metaclass=abc.ABCMeta):
21 # pylint: disable=missing-docstring
22 # We inherit the interfaces here from concurrent.futures.
24 """Future interface.
26 This interface is based on :class:`concurrent.futures.Future`.
27 """
29 @abc.abstractmethod
30 def cancel(self):
31 raise NotImplementedError()
33 @abc.abstractmethod
34 def cancelled(self):
35 raise NotImplementedError()
37 @abc.abstractmethod
38 def running(self):
39 raise NotImplementedError()
41 @abc.abstractmethod
42 def done(self):
43 raise NotImplementedError()
45 @abc.abstractmethod
46 def result(self, timeout=None):
47 raise NotImplementedError()
49 @abc.abstractmethod
50 def exception(self, timeout=None):
51 raise NotImplementedError()
53 @abc.abstractmethod
54 def add_done_callback(self, fn):
55 # pylint: disable=invalid-name
56 raise NotImplementedError()
58 @abc.abstractmethod
59 def set_result(self, result):
60 raise NotImplementedError()
62 @abc.abstractmethod
63 def set_exception(self, exception):
64 raise NotImplementedError()