grpcio-fips 1.70.0__3-cp313-cp313-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 (63) hide show
  1. grpc/__init__.py +2348 -0
  2. grpc/_auth.py +80 -0
  3. grpc/_channel.py +2267 -0
  4. grpc/_common.py +183 -0
  5. grpc/_compression.py +71 -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.cp313-win_amd64.pyd +0 -0
  10. grpc/_grpcio_metadata.py +1 -0
  11. grpc/_interceptor.py +813 -0
  12. grpc/_observability.py +299 -0
  13. grpc/_plugin_wrapping.py +136 -0
  14. grpc/_runtime_protos.py +165 -0
  15. grpc/_server.py +1528 -0
  16. grpc/_simple_stubs.py +588 -0
  17. grpc/_typing.py +95 -0
  18. grpc/_utilities.py +222 -0
  19. grpc/aio/__init__.py +95 -0
  20. grpc/aio/_base_call.py +257 -0
  21. grpc/aio/_base_channel.py +364 -0
  22. grpc/aio/_base_server.py +385 -0
  23. grpc/aio/_call.py +764 -0
  24. grpc/aio/_channel.py +627 -0
  25. grpc/aio/_interceptor.py +1178 -0
  26. grpc/aio/_metadata.py +137 -0
  27. grpc/aio/_server.py +239 -0
  28. grpc/aio/_typing.py +43 -0
  29. grpc/aio/_utils.py +22 -0
  30. grpc/beta/__init__.py +13 -0
  31. grpc/beta/_client_adaptations.py +1015 -0
  32. grpc/beta/_metadata.py +56 -0
  33. grpc/beta/_server_adaptations.py +465 -0
  34. grpc/beta/implementations.py +345 -0
  35. grpc/beta/interfaces.py +163 -0
  36. grpc/beta/utilities.py +153 -0
  37. grpc/experimental/__init__.py +134 -0
  38. grpc/experimental/aio/__init__.py +16 -0
  39. grpc/experimental/gevent.py +27 -0
  40. grpc/experimental/session_cache.py +45 -0
  41. grpc/framework/__init__.py +13 -0
  42. grpc/framework/common/__init__.py +13 -0
  43. grpc/framework/common/cardinality.py +26 -0
  44. grpc/framework/common/style.py +24 -0
  45. grpc/framework/foundation/__init__.py +13 -0
  46. grpc/framework/foundation/abandonment.py +22 -0
  47. grpc/framework/foundation/callable_util.py +98 -0
  48. grpc/framework/foundation/future.py +219 -0
  49. grpc/framework/foundation/logging_pool.py +72 -0
  50. grpc/framework/foundation/stream.py +43 -0
  51. grpc/framework/foundation/stream_util.py +148 -0
  52. grpc/framework/interfaces/__init__.py +13 -0
  53. grpc/framework/interfaces/base/__init__.py +13 -0
  54. grpc/framework/interfaces/base/base.py +328 -0
  55. grpc/framework/interfaces/base/utilities.py +83 -0
  56. grpc/framework/interfaces/face/__init__.py +13 -0
  57. grpc/framework/interfaces/face/face.py +1084 -0
  58. grpc/framework/interfaces/face/utilities.py +245 -0
  59. grpcio_fips-1.70.0.dist-info/METADATA +142 -0
  60. grpcio_fips-1.70.0.dist-info/RECORD +63 -0
  61. grpcio_fips-1.70.0.dist-info/WHEEL +5 -0
  62. grpcio_fips-1.70.0.dist-info/licenses/LICENSE +610 -0
  63. grpcio_fips-1.70.0.dist-info/top_level.txt +1 -0
grpc/_utilities.py ADDED
@@ -0,0 +1,222 @@
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
+
33
+ class RpcMethodHandler(
34
+ collections.namedtuple(
35
+ "_RpcMethodHandler",
36
+ (
37
+ "request_streaming",
38
+ "response_streaming",
39
+ "request_deserializer",
40
+ "response_serializer",
41
+ "unary_unary",
42
+ "unary_stream",
43
+ "stream_unary",
44
+ "stream_stream",
45
+ ),
46
+ ),
47
+ grpc.RpcMethodHandler,
48
+ ):
49
+ pass
50
+
51
+
52
+ class DictionaryGenericHandler(grpc.ServiceRpcHandler):
53
+ _name: str
54
+ _method_handlers: Dict[str, grpc.RpcMethodHandler]
55
+
56
+ def __init__(
57
+ self, service: str, method_handlers: Dict[str, grpc.RpcMethodHandler]
58
+ ):
59
+ self._name = service
60
+ self._method_handlers = {
61
+ _common.fully_qualified_method(service, method): method_handler
62
+ for method, method_handler in method_handlers.items()
63
+ }
64
+
65
+ def service_name(self) -> str:
66
+ return self._name
67
+
68
+ def service(
69
+ self, handler_call_details: grpc.HandlerCallDetails
70
+ ) -> Optional[grpc.RpcMethodHandler]:
71
+ details_method = handler_call_details.method
72
+ return self._method_handlers.get(
73
+ details_method
74
+ ) # pytype: disable=attribute-error
75
+
76
+
77
+ class _ChannelReadyFuture(grpc.Future):
78
+ _condition: threading.Condition
79
+ _channel: grpc.Channel
80
+ _matured: bool
81
+ _cancelled: bool
82
+ _done_callbacks: Sequence[Callable]
83
+
84
+ def __init__(self, channel: grpc.Channel):
85
+ self._condition = threading.Condition()
86
+ self._channel = channel
87
+
88
+ self._matured = False
89
+ self._cancelled = False
90
+ self._done_callbacks = []
91
+
92
+ def _block(self, timeout: Optional[float]) -> None:
93
+ until = None if timeout is None else time.time() + timeout
94
+ with self._condition:
95
+ while True:
96
+ if self._cancelled:
97
+ raise grpc.FutureCancelledError()
98
+ elif self._matured:
99
+ return
100
+ else:
101
+ if until is None:
102
+ self._condition.wait()
103
+ else:
104
+ remaining = until - time.time()
105
+ if remaining < 0:
106
+ raise grpc.FutureTimeoutError()
107
+ else:
108
+ self._condition.wait(timeout=remaining)
109
+
110
+ def _update(self, connectivity: Optional[grpc.ChannelConnectivity]) -> None:
111
+ with self._condition:
112
+ if (
113
+ not self._cancelled
114
+ and connectivity is grpc.ChannelConnectivity.READY
115
+ ):
116
+ self._matured = True
117
+ self._channel.unsubscribe(self._update)
118
+ self._condition.notify_all()
119
+ done_callbacks = tuple(self._done_callbacks)
120
+ self._done_callbacks = None
121
+ else:
122
+ return
123
+
124
+ for done_callback in done_callbacks:
125
+ try:
126
+ done_callback(self)
127
+ except Exception: # pylint: disable=broad-except
128
+ _LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
129
+
130
+ def cancel(self) -> bool:
131
+ with self._condition:
132
+ if not self._matured:
133
+ self._cancelled = True
134
+ self._channel.unsubscribe(self._update)
135
+ self._condition.notify_all()
136
+ done_callbacks = tuple(self._done_callbacks)
137
+ self._done_callbacks = None
138
+ else:
139
+ return False
140
+
141
+ for done_callback in done_callbacks:
142
+ try:
143
+ done_callback(self)
144
+ except Exception: # pylint: disable=broad-except
145
+ _LOGGER.exception(_DONE_CALLBACK_EXCEPTION_LOG_MESSAGE)
146
+
147
+ return True
148
+
149
+ def cancelled(self) -> bool:
150
+ with self._condition:
151
+ return self._cancelled
152
+
153
+ def running(self) -> bool:
154
+ with self._condition:
155
+ return not self._cancelled and not self._matured
156
+
157
+ def done(self) -> bool:
158
+ with self._condition:
159
+ return self._cancelled or self._matured
160
+
161
+ def result(self, timeout: Optional[float] = None) -> None:
162
+ self._block(timeout)
163
+
164
+ def exception(self, timeout: Optional[float] = None) -> None:
165
+ self._block(timeout)
166
+
167
+ def traceback(self, timeout: Optional[float] = None) -> None:
168
+ self._block(timeout)
169
+
170
+ def add_done_callback(self, fn: DoneCallbackType):
171
+ with self._condition:
172
+ if not self._cancelled and not self._matured:
173
+ self._done_callbacks.append(fn)
174
+ return
175
+
176
+ fn(self)
177
+
178
+ def start(self):
179
+ with self._condition:
180
+ self._channel.subscribe(self._update, try_to_connect=True)
181
+
182
+ def __del__(self):
183
+ with self._condition:
184
+ if not self._cancelled and not self._matured:
185
+ self._channel.unsubscribe(self._update)
186
+
187
+
188
+ def channel_ready_future(channel: grpc.Channel) -> _ChannelReadyFuture:
189
+ ready_future = _ChannelReadyFuture(channel)
190
+ ready_future.start()
191
+ return ready_future
192
+
193
+
194
+ def first_version_is_lower(version1: str, version2: str) -> bool:
195
+ """
196
+ Compares two versions in the format '1.60.1' or '1.60.1.dev0'.
197
+
198
+ This method will be used in all stubs generated by grpcio-tools to check whether
199
+ the stub version is compatible with the runtime grpcio.
200
+
201
+ Args:
202
+ version1: The first version string.
203
+ version2: The second version string.
204
+
205
+ Returns:
206
+ True if version1 is lower, False otherwise.
207
+ """
208
+ version1_list = version1.split(".")
209
+ version2_list = version2.split(".")
210
+
211
+ try:
212
+ for i in range(3):
213
+ if int(version1_list[i]) < int(version2_list[i]):
214
+ return True
215
+ elif int(version1_list[i]) > int(version2_list[i]):
216
+ return False
217
+ except ValueError:
218
+ # Return false in case we can't convert version to int.
219
+ return False
220
+
221
+ # The version without dev0 will be considered lower.
222
+ return len(version1_list) < len(version2_list)
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,257 @@
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 Any, AsyncIterator, Generator, 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(
139
+ Generic[RequestType, ResponseType], Call, metaclass=ABCMeta
140
+ ):
141
+ """The abstract base class of a unary-unary RPC on the client-side."""
142
+
143
+ @abstractmethod
144
+ def __await__(self) -> Generator[Any, None, 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(
153
+ Generic[RequestType, ResponseType], Call, metaclass=ABCMeta
154
+ ):
155
+ @abstractmethod
156
+ def __aiter__(self) -> AsyncIterator[ResponseType]:
157
+ """Returns the async iterator representation that yields messages.
158
+
159
+ Under the hood, it is calling the "read" method.
160
+
161
+ Returns:
162
+ An async iterator object that yields messages.
163
+ """
164
+
165
+ @abstractmethod
166
+ async def read(self) -> Union[EOFType, ResponseType]:
167
+ """Reads one message from the stream.
168
+
169
+ Read operations must be serialized when called from multiple
170
+ coroutines.
171
+
172
+ Note that the iterator and read/write APIs may not be mixed on
173
+ a single RPC.
174
+
175
+ Returns:
176
+ A response message, or an `grpc.aio.EOF` to indicate the end of the
177
+ stream.
178
+ """
179
+
180
+
181
+ class StreamUnaryCall(
182
+ Generic[RequestType, ResponseType], Call, metaclass=ABCMeta
183
+ ):
184
+ @abstractmethod
185
+ async def write(self, request: RequestType) -> None:
186
+ """Writes one message to the stream.
187
+
188
+ Note that the iterator and read/write APIs may not be mixed on
189
+ a single RPC.
190
+
191
+ Raises:
192
+ An RpcError exception if the write failed.
193
+ """
194
+
195
+ @abstractmethod
196
+ async def done_writing(self) -> None:
197
+ """Notifies server that the client is done sending messages.
198
+
199
+ After done_writing is called, any additional invocation to the write
200
+ function will fail. This function is idempotent.
201
+ """
202
+
203
+ @abstractmethod
204
+ def __await__(self) -> Generator[Any, None, ResponseType]:
205
+ """Await the response message to be ready.
206
+
207
+ Returns:
208
+ The response message of the stream.
209
+ """
210
+
211
+
212
+ class StreamStreamCall(
213
+ Generic[RequestType, ResponseType], Call, metaclass=ABCMeta
214
+ ):
215
+ @abstractmethod
216
+ def __aiter__(self) -> AsyncIterator[ResponseType]:
217
+ """Returns the async iterator representation that yields messages.
218
+
219
+ Under the hood, it is calling the "read" method.
220
+
221
+ Returns:
222
+ An async iterator object that yields messages.
223
+ """
224
+
225
+ @abstractmethod
226
+ async def read(self) -> Union[EOFType, ResponseType]:
227
+ """Reads one message from the stream.
228
+
229
+ Read operations must be serialized when called from multiple
230
+ coroutines.
231
+
232
+ Note that the iterator and read/write APIs may not be mixed on
233
+ a single RPC.
234
+
235
+ Returns:
236
+ A response message, or an `grpc.aio.EOF` to indicate the end of the
237
+ stream.
238
+ """
239
+
240
+ @abstractmethod
241
+ async def write(self, request: RequestType) -> None:
242
+ """Writes one message to the stream.
243
+
244
+ Note that the iterator and read/write APIs may not be mixed on
245
+ a single RPC.
246
+
247
+ Raises:
248
+ An RpcError exception if the write failed.
249
+ """
250
+
251
+ @abstractmethod
252
+ async def done_writing(self) -> None:
253
+ """Notifies server that the client is done sending messages.
254
+
255
+ After done_writing is called, any additional invocation to the write
256
+ function will fail. This function is idempotent.
257
+ """