grpcio-fips 1.53.2__0-cp38-cp38-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. grpc/__init__.py +2174 -0
  2. grpc/_auth.py +68 -0
  3. grpc/_channel.py +1767 -0
  4. grpc/_common.py +177 -0
  5. grpc/_compression.py +63 -0
  6. grpc/_cython/__init__.py +13 -0
  7. grpc/_cython/_credentials/roots.pem +4337 -0
  8. grpc/_cython/_cygrpc/__init__.py +13 -0
  9. grpc/_cython/cygrpc.cp38-win_amd64.pyd +0 -0
  10. grpc/_grpcio_metadata.py +1 -0
  11. grpc/_interceptor.py +638 -0
  12. grpc/_plugin_wrapping.py +121 -0
  13. grpc/_runtime_protos.py +159 -0
  14. grpc/_server.py +1141 -0
  15. grpc/_simple_stubs.py +486 -0
  16. grpc/_typing.py +58 -0
  17. grpc/_utilities.py +180 -0
  18. grpc/aio/__init__.py +95 -0
  19. grpc/aio/_base_call.py +248 -0
  20. grpc/aio/_base_channel.py +348 -0
  21. grpc/aio/_base_server.py +369 -0
  22. grpc/aio/_call.py +649 -0
  23. grpc/aio/_channel.py +492 -0
  24. grpc/aio/_interceptor.py +1003 -0
  25. grpc/aio/_metadata.py +120 -0
  26. grpc/aio/_server.py +209 -0
  27. grpc/aio/_typing.py +35 -0
  28. grpc/aio/_utils.py +22 -0
  29. grpc/beta/__init__.py +13 -0
  30. grpc/beta/_client_adaptations.py +706 -0
  31. grpc/beta/_metadata.py +52 -0
  32. grpc/beta/_server_adaptations.py +385 -0
  33. grpc/beta/implementations.py +311 -0
  34. grpc/beta/interfaces.py +163 -0
  35. grpc/beta/utilities.py +149 -0
  36. grpc/experimental/__init__.py +128 -0
  37. grpc/experimental/aio/__init__.py +16 -0
  38. grpc/experimental/gevent.py +27 -0
  39. grpc/experimental/session_cache.py +45 -0
  40. grpc/framework/__init__.py +13 -0
  41. grpc/framework/common/__init__.py +13 -0
  42. grpc/framework/common/cardinality.py +26 -0
  43. grpc/framework/common/style.py +24 -0
  44. grpc/framework/foundation/__init__.py +13 -0
  45. grpc/framework/foundation/abandonment.py +22 -0
  46. grpc/framework/foundation/callable_util.py +94 -0
  47. grpc/framework/foundation/future.py +219 -0
  48. grpc/framework/foundation/logging_pool.py +71 -0
  49. grpc/framework/foundation/stream.py +43 -0
  50. grpc/framework/foundation/stream_util.py +148 -0
  51. grpc/framework/interfaces/__init__.py +13 -0
  52. grpc/framework/interfaces/base/__init__.py +13 -0
  53. grpc/framework/interfaces/base/base.py +325 -0
  54. grpc/framework/interfaces/base/utilities.py +71 -0
  55. grpc/framework/interfaces/face/__init__.py +13 -0
  56. grpc/framework/interfaces/face/face.py +1049 -0
  57. grpc/framework/interfaces/face/utilities.py +168 -0
  58. grpcio_fips-1.53.2.dist-info/LICENSE +610 -0
  59. grpcio_fips-1.53.2.dist-info/METADATA +139 -0
  60. grpcio_fips-1.53.2.dist-info/RECORD +62 -0
  61. grpcio_fips-1.53.2.dist-info/WHEEL +5 -0
  62. grpcio_fips-1.53.2.dist-info/top_level.txt +1 -0
grpc/_utilities.py ADDED
@@ -0,0 +1,180 @@
1
+ # Copyright 2015 gRPC authors.
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
+ """Internal utilities for gRPC Python."""
15
+
16
+ import collections
17
+ import logging
18
+ import threading
19
+ import time
20
+ from typing import Callable, Dict, Optional, Sequence
21
+
22
+ import grpc # pytype: disable=pyi-error
23
+ from grpc import _common # pytype: disable=pyi-error
24
+ from grpc._typing import DoneCallbackType
25
+
26
+ _LOGGER = logging.getLogger(__name__)
27
+
28
+ _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = (
29
+ 'Exception calling connectivity future "done" callback!')
30
+
31
+
32
+ class RpcMethodHandler(
33
+ collections.namedtuple('_RpcMethodHandler', (
34
+ 'request_streaming',
35
+ 'response_streaming',
36
+ 'request_deserializer',
37
+ 'response_serializer',
38
+ 'unary_unary',
39
+ 'unary_stream',
40
+ 'stream_unary',
41
+ 'stream_stream',
42
+ )), grpc.RpcMethodHandler):
43
+ pass
44
+
45
+
46
+ class DictionaryGenericHandler(grpc.ServiceRpcHandler):
47
+ _name: str
48
+ _method_handlers: Dict[str, grpc.RpcMethodHandler]
49
+
50
+ def __init__(self, service: str,
51
+ method_handlers: Dict[str, grpc.RpcMethodHandler]):
52
+ self._name = service
53
+ self._method_handlers = {
54
+ _common.fully_qualified_method(service, method): method_handler
55
+ for method, method_handler in method_handlers.items()
56
+ }
57
+
58
+ def service_name(self) -> str:
59
+ return self._name
60
+
61
+ def service(
62
+ self, handler_call_details: grpc.HandlerCallDetails
63
+ ) -> Optional[grpc.RpcMethodHandler]:
64
+ details_method = handler_call_details.method
65
+ return self._method_handlers.get(details_method) # pytype: disable=attribute-error
66
+
67
+
68
+ class _ChannelReadyFuture(grpc.Future):
69
+ _condition: threading.Condition
70
+ _channel: grpc.Channel
71
+ _matured: bool
72
+ _cancelled: bool
73
+ _done_callbacks: Sequence[Callable]
74
+
75
+ def __init__(self, channel: grpc.Channel):
76
+ self._condition = threading.Condition()
77
+ self._channel = channel
78
+
79
+ self._matured = False
80
+ self._cancelled = False
81
+ self._done_callbacks = []
82
+
83
+ def _block(self, timeout: Optional[float]) -> None:
84
+ until = None if timeout is None else time.time() + timeout
85
+ with self._condition:
86
+ while True:
87
+ if self._cancelled:
88
+ raise grpc.FutureCancelledError()
89
+ elif self._matured:
90
+ return
91
+ else:
92
+ if until is None:
93
+ self._condition.wait()
94
+ else:
95
+ remaining = until - time.time()
96
+ if remaining < 0:
97
+ raise grpc.FutureTimeoutError()
98
+ else:
99
+ self._condition.wait(timeout=remaining)
100
+
101
+ def _update(self, connectivity: Optional[grpc.ChannelConnectivity]) -> None:
102
+ with self._condition:
103
+ if (not self._cancelled and
104
+ connectivity is grpc.ChannelConnectivity.READY):
105
+ self._matured = True
106
+ self._channel.unsubscribe(self._update)
107
+ self._condition.notify_all()
108
+ done_callbacks = tuple(self._done_callbacks)
109
+ self._done_callbacks = None
110
+ else:
111
+ return
112
+
113
+ for done_callback in done_callbacks:
114
+ try:
115
+ done_callback(self)
116
+ except Exception: # pylint: disable=broad-except
117
+ _LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
118
+
119
+ def cancel(self) -> bool:
120
+ with self._condition:
121
+ if not self._matured:
122
+ self._cancelled = True
123
+ self._channel.unsubscribe(self._update)
124
+ self._condition.notify_all()
125
+ done_callbacks = tuple(self._done_callbacks)
126
+ self._done_callbacks = None
127
+ else:
128
+ return False
129
+
130
+ for done_callback in done_callbacks:
131
+ try:
132
+ done_callback(self)
133
+ except Exception: # pylint: disable=broad-except
134
+ _LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
135
+
136
+ return True
137
+
138
+ def cancelled(self) -> bool:
139
+ with self._condition:
140
+ return self._cancelled
141
+
142
+ def running(self) -> bool:
143
+ with self._condition:
144
+ return not self._cancelled and not self._matured
145
+
146
+ def done(self) -> bool:
147
+ with self._condition:
148
+ return self._cancelled or self._matured
149
+
150
+ def result(self, timeout: Optional[float] = None) -> None:
151
+ self._block(timeout)
152
+
153
+ def exception(self, timeout: Optional[float] = None) -> None:
154
+ self._block(timeout)
155
+
156
+ def traceback(self, timeout: Optional[float] = None) -> None:
157
+ self._block(timeout)
158
+
159
+ def add_done_callback(self, fn: DoneCallbackType):
160
+ with self._condition:
161
+ if not self._cancelled and not self._matured:
162
+ self._done_callbacks.append(fn)
163
+ return
164
+
165
+ fn(self)
166
+
167
+ def start(self):
168
+ with self._condition:
169
+ self._channel.subscribe(self._update, try_to_connect=True)
170
+
171
+ def __del__(self):
172
+ with self._condition:
173
+ if not self._cancelled and not self._matured:
174
+ self._channel.unsubscribe(self._update)
175
+
176
+
177
+ def channel_ready_future(channel: grpc.Channel) -> _ChannelReadyFuture:
178
+ ready_future = _ChannelReadyFuture(channel)
179
+ ready_future.start()
180
+ return ready_future
grpc/aio/__init__.py ADDED
@@ -0,0 +1,95 @@
1
+ # Copyright 2019 gRPC authors.
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
+ """gRPC's Asynchronous Python API.
15
+
16
+ gRPC Async API objects may only be used on the thread on which they were
17
+ created. AsyncIO doesn't provide thread safety for most of its APIs.
18
+ """
19
+
20
+ from typing import Any, Optional, Sequence, Tuple
21
+
22
+ import grpc
23
+ from grpc._cython.cygrpc import AbortError
24
+ from grpc._cython.cygrpc import BaseError
25
+ from grpc._cython.cygrpc import EOF
26
+ from grpc._cython.cygrpc import InternalError
27
+ from grpc._cython.cygrpc import UsageError
28
+ from grpc._cython.cygrpc import init_grpc_aio
29
+ from grpc._cython.cygrpc import shutdown_grpc_aio
30
+
31
+ from ._base_call import Call
32
+ from ._base_call import RpcContext
33
+ from ._base_call import StreamStreamCall
34
+ from ._base_call import StreamUnaryCall
35
+ from ._base_call import UnaryStreamCall
36
+ from ._base_call import UnaryUnaryCall
37
+ from ._base_channel import Channel
38
+ from ._base_channel import StreamStreamMultiCallable
39
+ from ._base_channel import StreamUnaryMultiCallable
40
+ from ._base_channel import UnaryStreamMultiCallable
41
+ from ._base_channel import UnaryUnaryMultiCallable
42
+ from ._base_server import Server
43
+ from ._base_server import ServicerContext
44
+ from ._call import AioRpcError
45
+ from ._channel import insecure_channel
46
+ from ._channel import secure_channel
47
+ from ._interceptor import ClientCallDetails
48
+ from ._interceptor import ClientInterceptor
49
+ from ._interceptor import InterceptedUnaryUnaryCall
50
+ from ._interceptor import ServerInterceptor
51
+ from ._interceptor import StreamStreamClientInterceptor
52
+ from ._interceptor import StreamUnaryClientInterceptor
53
+ from ._interceptor import UnaryStreamClientInterceptor
54
+ from ._interceptor import UnaryUnaryClientInterceptor
55
+ from ._metadata import Metadata
56
+ from ._server import server
57
+ from ._typing import ChannelArgumentType
58
+
59
+ ################################### __all__ #################################
60
+
61
+ __all__ = (
62
+ 'init_grpc_aio',
63
+ 'shutdown_grpc_aio',
64
+ 'AioRpcError',
65
+ 'RpcContext',
66
+ 'Call',
67
+ 'UnaryUnaryCall',
68
+ 'UnaryStreamCall',
69
+ 'StreamUnaryCall',
70
+ 'StreamStreamCall',
71
+ 'Channel',
72
+ 'UnaryUnaryMultiCallable',
73
+ 'UnaryStreamMultiCallable',
74
+ 'StreamUnaryMultiCallable',
75
+ 'StreamStreamMultiCallable',
76
+ 'ClientCallDetails',
77
+ 'ClientInterceptor',
78
+ 'UnaryStreamClientInterceptor',
79
+ 'UnaryUnaryClientInterceptor',
80
+ 'StreamUnaryClientInterceptor',
81
+ 'StreamStreamClientInterceptor',
82
+ 'InterceptedUnaryUnaryCall',
83
+ 'ServerInterceptor',
84
+ 'insecure_channel',
85
+ 'server',
86
+ 'Server',
87
+ 'ServicerContext',
88
+ 'EOF',
89
+ 'secure_channel',
90
+ 'AbortError',
91
+ 'BaseError',
92
+ 'UsageError',
93
+ 'InternalError',
94
+ 'Metadata',
95
+ )
grpc/aio/_base_call.py ADDED
@@ -0,0 +1,248 @@
1
+ # Copyright 2019 The gRPC Authors
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
+ """Abstract base classes for client-side Call objects.
15
+
16
+ Call objects represents the RPC itself, and offer methods to access / modify
17
+ its information. They also offer methods to manipulate the life-cycle of the
18
+ RPC, e.g. cancellation.
19
+ """
20
+
21
+ from abc import ABCMeta
22
+ from abc import abstractmethod
23
+ from typing import AsyncIterable, Awaitable, Generic, Optional, Union
24
+
25
+ import grpc
26
+
27
+ from ._metadata import Metadata
28
+ from ._typing import DoneCallbackType
29
+ from ._typing import EOFType
30
+ from ._typing import RequestType
31
+ from ._typing import ResponseType
32
+
33
+ __all__ = 'RpcContext', 'Call', 'UnaryUnaryCall', 'UnaryStreamCall'
34
+
35
+
36
+ class RpcContext(metaclass=ABCMeta):
37
+ """Provides RPC-related information and action."""
38
+
39
+ @abstractmethod
40
+ def cancelled(self) -> bool:
41
+ """Return True if the RPC is cancelled.
42
+
43
+ The RPC is cancelled when the cancellation was requested with cancel().
44
+
45
+ Returns:
46
+ A bool indicates whether the RPC is cancelled or not.
47
+ """
48
+
49
+ @abstractmethod
50
+ def done(self) -> bool:
51
+ """Return True if the RPC is done.
52
+
53
+ An RPC is done if the RPC is completed, cancelled or aborted.
54
+
55
+ Returns:
56
+ A bool indicates if the RPC is done.
57
+ """
58
+
59
+ @abstractmethod
60
+ def time_remaining(self) -> Optional[float]:
61
+ """Describes the length of allowed time remaining for the RPC.
62
+
63
+ Returns:
64
+ A nonnegative float indicating the length of allowed time in seconds
65
+ remaining for the RPC to complete before it is considered to have
66
+ timed out, or None if no deadline was specified for the RPC.
67
+ """
68
+
69
+ @abstractmethod
70
+ def cancel(self) -> bool:
71
+ """Cancels the RPC.
72
+
73
+ Idempotent and has no effect if the RPC has already terminated.
74
+
75
+ Returns:
76
+ A bool indicates if the cancellation is performed or not.
77
+ """
78
+
79
+ @abstractmethod
80
+ def add_done_callback(self, callback: DoneCallbackType) -> None:
81
+ """Registers a callback to be called on RPC termination.
82
+
83
+ Args:
84
+ callback: A callable object will be called with the call object as
85
+ its only argument.
86
+ """
87
+
88
+
89
+ class Call(RpcContext, metaclass=ABCMeta):
90
+ """The abstract base class of an RPC on the client-side."""
91
+
92
+ @abstractmethod
93
+ async def initial_metadata(self) -> Metadata:
94
+ """Accesses the initial metadata sent by the server.
95
+
96
+ Returns:
97
+ The initial :term:`metadata`.
98
+ """
99
+
100
+ @abstractmethod
101
+ async def trailing_metadata(self) -> Metadata:
102
+ """Accesses the trailing metadata sent by the server.
103
+
104
+ Returns:
105
+ The trailing :term:`metadata`.
106
+ """
107
+
108
+ @abstractmethod
109
+ async def code(self) -> grpc.StatusCode:
110
+ """Accesses the status code sent by the server.
111
+
112
+ Returns:
113
+ The StatusCode value for the RPC.
114
+ """
115
+
116
+ @abstractmethod
117
+ async def details(self) -> str:
118
+ """Accesses the details sent by the server.
119
+
120
+ Returns:
121
+ The details string of the RPC.
122
+ """
123
+
124
+ @abstractmethod
125
+ async def wait_for_connection(self) -> None:
126
+ """Waits until connected to peer and raises aio.AioRpcError if failed.
127
+
128
+ This is an EXPERIMENTAL method.
129
+
130
+ This method ensures the RPC has been successfully connected. Otherwise,
131
+ an AioRpcError will be raised to explain the reason of the connection
132
+ failure.
133
+
134
+ This method is recommended for building retry mechanisms.
135
+ """
136
+
137
+
138
+ class UnaryUnaryCall(Generic[RequestType, ResponseType],
139
+ Call,
140
+ metaclass=ABCMeta):
141
+ """The abstract base class of an unary-unary RPC on the client-side."""
142
+
143
+ @abstractmethod
144
+ def __await__(self) -> Awaitable[ResponseType]:
145
+ """Await the response message to be ready.
146
+
147
+ Returns:
148
+ The response message of the RPC.
149
+ """
150
+
151
+
152
+ class UnaryStreamCall(Generic[RequestType, ResponseType],
153
+ Call,
154
+ metaclass=ABCMeta):
155
+
156
+ @abstractmethod
157
+ def __aiter__(self) -> AsyncIterable[ResponseType]:
158
+ """Returns the async iterable representation that yields messages.
159
+
160
+ Under the hood, it is calling the "read" method.
161
+
162
+ Returns:
163
+ An async iterable object that yields messages.
164
+ """
165
+
166
+ @abstractmethod
167
+ async def read(self) -> Union[EOFType, ResponseType]:
168
+ """Reads one message from the stream.
169
+
170
+ Read operations must be serialized when called from multiple
171
+ coroutines.
172
+
173
+ Returns:
174
+ A response message, or an `grpc.aio.EOF` to indicate the end of the
175
+ stream.
176
+ """
177
+
178
+
179
+ class StreamUnaryCall(Generic[RequestType, ResponseType],
180
+ Call,
181
+ metaclass=ABCMeta):
182
+
183
+ @abstractmethod
184
+ async def write(self, request: RequestType) -> None:
185
+ """Writes one message to the stream.
186
+
187
+ Raises:
188
+ An RpcError exception if the write failed.
189
+ """
190
+
191
+ @abstractmethod
192
+ async def done_writing(self) -> None:
193
+ """Notifies server that the client is done sending messages.
194
+
195
+ After done_writing is called, any additional invocation to the write
196
+ function will fail. This function is idempotent.
197
+ """
198
+
199
+ @abstractmethod
200
+ def __await__(self) -> Awaitable[ResponseType]:
201
+ """Await the response message to be ready.
202
+
203
+ Returns:
204
+ The response message of the stream.
205
+ """
206
+
207
+
208
+ class StreamStreamCall(Generic[RequestType, ResponseType],
209
+ Call,
210
+ metaclass=ABCMeta):
211
+
212
+ @abstractmethod
213
+ def __aiter__(self) -> AsyncIterable[ResponseType]:
214
+ """Returns the async iterable representation that yields messages.
215
+
216
+ Under the hood, it is calling the "read" method.
217
+
218
+ Returns:
219
+ An async iterable object that yields messages.
220
+ """
221
+
222
+ @abstractmethod
223
+ async def read(self) -> Union[EOFType, ResponseType]:
224
+ """Reads one message from the stream.
225
+
226
+ Read operations must be serialized when called from multiple
227
+ coroutines.
228
+
229
+ Returns:
230
+ A response message, or an `grpc.aio.EOF` to indicate the end of the
231
+ stream.
232
+ """
233
+
234
+ @abstractmethod
235
+ async def write(self, request: RequestType) -> None:
236
+ """Writes one message to the stream.
237
+
238
+ Raises:
239
+ An RpcError exception if the write failed.
240
+ """
241
+
242
+ @abstractmethod
243
+ async def done_writing(self) -> None:
244
+ """Notifies server that the client is done sending messages.
245
+
246
+ After done_writing is called, any additional invocation to the write
247
+ function will fail. This function is idempotent.
248
+ """