Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/api_core/future/base.py: 68%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

31 statements  

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. 

14 

15"""Abstract and helper bases for Future implementations.""" 

16 

17import abc 

18 

19 

20class Future(object, metaclass=abc.ABCMeta): 

21 # pylint: disable=missing-docstring 

22 # We inherit the interfaces here from concurrent.futures. 

23 

24 """Future interface. 

25 

26 This interface is based on :class:`concurrent.futures.Future`. 

27 """ 

28 

29 @abc.abstractmethod 

30 def cancel(self): 

31 raise NotImplementedError() 

32 

33 @abc.abstractmethod 

34 def cancelled(self): 

35 raise NotImplementedError() 

36 

37 @abc.abstractmethod 

38 def running(self): 

39 raise NotImplementedError() 

40 

41 @abc.abstractmethod 

42 def done(self): 

43 raise NotImplementedError() 

44 

45 @abc.abstractmethod 

46 def result(self, timeout=None): 

47 raise NotImplementedError() 

48 

49 @abc.abstractmethod 

50 def exception(self, timeout=None): 

51 raise NotImplementedError() 

52 

53 @abc.abstractmethod 

54 def add_done_callback(self, fn): 

55 # pylint: disable=invalid-name 

56 raise NotImplementedError() 

57 

58 @abc.abstractmethod 

59 def set_result(self, result): 

60 raise NotImplementedError() 

61 

62 @abc.abstractmethod 

63 def set_exception(self, exception): 

64 raise NotImplementedError()