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.
- grpc/__init__.py +2174 -0
- grpc/_auth.py +68 -0
- grpc/_channel.py +1767 -0
- grpc/_common.py +177 -0
- grpc/_compression.py +63 -0
- grpc/_cython/__init__.py +13 -0
- grpc/_cython/_credentials/roots.pem +4337 -0
- grpc/_cython/_cygrpc/__init__.py +13 -0
- grpc/_cython/cygrpc.cp38-win_amd64.pyd +0 -0
- grpc/_grpcio_metadata.py +1 -0
- grpc/_interceptor.py +638 -0
- grpc/_plugin_wrapping.py +121 -0
- grpc/_runtime_protos.py +159 -0
- grpc/_server.py +1141 -0
- grpc/_simple_stubs.py +486 -0
- grpc/_typing.py +58 -0
- grpc/_utilities.py +180 -0
- grpc/aio/__init__.py +95 -0
- grpc/aio/_base_call.py +248 -0
- grpc/aio/_base_channel.py +348 -0
- grpc/aio/_base_server.py +369 -0
- grpc/aio/_call.py +649 -0
- grpc/aio/_channel.py +492 -0
- grpc/aio/_interceptor.py +1003 -0
- grpc/aio/_metadata.py +120 -0
- grpc/aio/_server.py +209 -0
- grpc/aio/_typing.py +35 -0
- grpc/aio/_utils.py +22 -0
- grpc/beta/__init__.py +13 -0
- grpc/beta/_client_adaptations.py +706 -0
- grpc/beta/_metadata.py +52 -0
- grpc/beta/_server_adaptations.py +385 -0
- grpc/beta/implementations.py +311 -0
- grpc/beta/interfaces.py +163 -0
- grpc/beta/utilities.py +149 -0
- grpc/experimental/__init__.py +128 -0
- grpc/experimental/aio/__init__.py +16 -0
- grpc/experimental/gevent.py +27 -0
- grpc/experimental/session_cache.py +45 -0
- grpc/framework/__init__.py +13 -0
- grpc/framework/common/__init__.py +13 -0
- grpc/framework/common/cardinality.py +26 -0
- grpc/framework/common/style.py +24 -0
- grpc/framework/foundation/__init__.py +13 -0
- grpc/framework/foundation/abandonment.py +22 -0
- grpc/framework/foundation/callable_util.py +94 -0
- grpc/framework/foundation/future.py +219 -0
- grpc/framework/foundation/logging_pool.py +71 -0
- grpc/framework/foundation/stream.py +43 -0
- grpc/framework/foundation/stream_util.py +148 -0
- grpc/framework/interfaces/__init__.py +13 -0
- grpc/framework/interfaces/base/__init__.py +13 -0
- grpc/framework/interfaces/base/base.py +325 -0
- grpc/framework/interfaces/base/utilities.py +71 -0
- grpc/framework/interfaces/face/__init__.py +13 -0
- grpc/framework/interfaces/face/face.py +1049 -0
- grpc/framework/interfaces/face/utilities.py +168 -0
- grpcio_fips-1.53.2.dist-info/LICENSE +610 -0
- grpcio_fips-1.53.2.dist-info/METADATA +139 -0
- grpcio_fips-1.53.2.dist-info/RECORD +62 -0
- grpcio_fips-1.53.2.dist-info/WHEEL +5 -0
- grpcio_fips-1.53.2.dist-info/top_level.txt +1 -0
grpc/_plugin_wrapping.py
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
|
|
15
|
+
import collections
|
|
16
|
+
import logging
|
|
17
|
+
import threading
|
|
18
|
+
from typing import Callable, Optional, Type
|
|
19
|
+
|
|
20
|
+
import grpc
|
|
21
|
+
from grpc import _common
|
|
22
|
+
from grpc._cython import cygrpc
|
|
23
|
+
from grpc._typing import MetadataType
|
|
24
|
+
|
|
25
|
+
_LOGGER = logging.getLogger(__name__)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class _AuthMetadataContext(
|
|
29
|
+
collections.namedtuple('AuthMetadataContext', (
|
|
30
|
+
'service_url',
|
|
31
|
+
'method_name',
|
|
32
|
+
)), grpc.AuthMetadataContext):
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _CallbackState(object):
|
|
37
|
+
|
|
38
|
+
def __init__(self):
|
|
39
|
+
self.lock = threading.Lock()
|
|
40
|
+
self.called = False
|
|
41
|
+
self.exception = None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _AuthMetadataPluginCallback(grpc.AuthMetadataPluginCallback):
|
|
45
|
+
_state: _CallbackState
|
|
46
|
+
_callback: Callable
|
|
47
|
+
|
|
48
|
+
def __init__(self, state: _CallbackState, callback: Callable):
|
|
49
|
+
self._state = state
|
|
50
|
+
self._callback = callback
|
|
51
|
+
|
|
52
|
+
def __call__(self, metadata: MetadataType,
|
|
53
|
+
error: Optional[Type[BaseException]]):
|
|
54
|
+
with self._state.lock:
|
|
55
|
+
if self._state.exception is None:
|
|
56
|
+
if self._state.called:
|
|
57
|
+
raise RuntimeError(
|
|
58
|
+
'AuthMetadataPluginCallback invoked more than once!')
|
|
59
|
+
else:
|
|
60
|
+
self._state.called = True
|
|
61
|
+
else:
|
|
62
|
+
raise RuntimeError(
|
|
63
|
+
'AuthMetadataPluginCallback raised exception "{}"!'.format(
|
|
64
|
+
self._state.exception))
|
|
65
|
+
if error is None:
|
|
66
|
+
self._callback(metadata, cygrpc.StatusCode.ok, None)
|
|
67
|
+
else:
|
|
68
|
+
self._callback(None, cygrpc.StatusCode.internal,
|
|
69
|
+
_common.encode(str(error)))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class _Plugin(object):
|
|
73
|
+
_metadata_plugin: grpc.AuthMetadataPlugin
|
|
74
|
+
|
|
75
|
+
def __init__(self, metadata_plugin: grpc.AuthMetadataPlugin):
|
|
76
|
+
self._metadata_plugin = metadata_plugin
|
|
77
|
+
self._stored_ctx = None
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
import contextvars # pylint: disable=wrong-import-position
|
|
81
|
+
|
|
82
|
+
# The plugin may be invoked on a thread created by Core, which will not
|
|
83
|
+
# have the context propagated. This context is stored and installed in
|
|
84
|
+
# the thread invoking the plugin.
|
|
85
|
+
self._stored_ctx = contextvars.copy_context()
|
|
86
|
+
except ImportError:
|
|
87
|
+
# Support versions predating contextvars.
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
def __call__(self, service_url: str, method_name: str, callback: Callable):
|
|
91
|
+
context = _AuthMetadataContext(_common.decode(service_url),
|
|
92
|
+
_common.decode(method_name))
|
|
93
|
+
callback_state = _CallbackState()
|
|
94
|
+
try:
|
|
95
|
+
self._metadata_plugin(
|
|
96
|
+
context, _AuthMetadataPluginCallback(callback_state, callback))
|
|
97
|
+
except Exception as exception: # pylint: disable=broad-except
|
|
98
|
+
_LOGGER.exception(
|
|
99
|
+
'AuthMetadataPluginCallback "%s" raised exception!',
|
|
100
|
+
self._metadata_plugin)
|
|
101
|
+
with callback_state.lock:
|
|
102
|
+
callback_state.exception = exception
|
|
103
|
+
if callback_state.called:
|
|
104
|
+
return
|
|
105
|
+
callback(None, cygrpc.StatusCode.internal,
|
|
106
|
+
_common.encode(str(exception)))
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def metadata_plugin_call_credentials(
|
|
110
|
+
metadata_plugin: grpc.AuthMetadataPlugin,
|
|
111
|
+
name: Optional[str]) -> grpc.CallCredentials:
|
|
112
|
+
if name is None:
|
|
113
|
+
try:
|
|
114
|
+
effective_name = metadata_plugin.__name__
|
|
115
|
+
except AttributeError:
|
|
116
|
+
effective_name = metadata_plugin.__class__.__name__
|
|
117
|
+
else:
|
|
118
|
+
effective_name = name
|
|
119
|
+
return grpc.CallCredentials(
|
|
120
|
+
cygrpc.MetadataPluginCallCredentials(_Plugin(metadata_plugin),
|
|
121
|
+
_common.encode(effective_name)))
|
grpc/_runtime_protos.py
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Copyright 2020 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
|
+
|
|
15
|
+
import sys
|
|
16
|
+
import types
|
|
17
|
+
from typing import Tuple, Union
|
|
18
|
+
|
|
19
|
+
_REQUIRED_SYMBOLS = ("_protos", "_services", "_protos_and_services")
|
|
20
|
+
_MINIMUM_VERSION = (3, 5, 0)
|
|
21
|
+
|
|
22
|
+
_UNINSTALLED_TEMPLATE = "Install the grpcio-tools package (1.32.0+) to use the {} function."
|
|
23
|
+
_VERSION_ERROR_TEMPLATE = "The {} function is only on available on Python 3.X interpreters."
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _has_runtime_proto_symbols(mod: types.ModuleType) -> bool:
|
|
27
|
+
return all(hasattr(mod, sym) for sym in _REQUIRED_SYMBOLS)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _is_grpc_tools_importable() -> bool:
|
|
31
|
+
try:
|
|
32
|
+
import grpc_tools # pylint: disable=unused-import # pytype: disable=import-error
|
|
33
|
+
return True
|
|
34
|
+
except ImportError as e:
|
|
35
|
+
# NOTE: It's possible that we're encountering a transitive ImportError, so
|
|
36
|
+
# we check for that and re-raise if so.
|
|
37
|
+
if "grpc_tools" not in e.args[0]:
|
|
38
|
+
raise
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _call_with_lazy_import(
|
|
43
|
+
fn_name: str, protobuf_path: str
|
|
44
|
+
) -> Union[types.ModuleType, Tuple[types.ModuleType, types.ModuleType]]:
|
|
45
|
+
"""Calls one of the three functions, lazily importing grpc_tools.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
fn_name: The name of the function to import from grpc_tools.protoc.
|
|
49
|
+
protobuf_path: The path to import.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
The appropriate module object.
|
|
53
|
+
"""
|
|
54
|
+
if sys.version_info < _MINIMUM_VERSION:
|
|
55
|
+
raise NotImplementedError(_VERSION_ERROR_TEMPLATE.format(fn_name))
|
|
56
|
+
else:
|
|
57
|
+
if not _is_grpc_tools_importable():
|
|
58
|
+
raise NotImplementedError(_UNINSTALLED_TEMPLATE.format(fn_name))
|
|
59
|
+
import grpc_tools.protoc # pytype: disable=import-error
|
|
60
|
+
if _has_runtime_proto_symbols(grpc_tools.protoc):
|
|
61
|
+
fn = getattr(grpc_tools.protoc, '_' + fn_name)
|
|
62
|
+
return fn(protobuf_path)
|
|
63
|
+
else:
|
|
64
|
+
raise NotImplementedError(_UNINSTALLED_TEMPLATE.format(fn_name))
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def protos(protobuf_path): # pylint: disable=unused-argument
|
|
68
|
+
"""Returns a module generated by the indicated .proto file.
|
|
69
|
+
|
|
70
|
+
THIS IS AN EXPERIMENTAL API.
|
|
71
|
+
|
|
72
|
+
Use this function to retrieve classes corresponding to message
|
|
73
|
+
definitions in the .proto file.
|
|
74
|
+
|
|
75
|
+
To inspect the contents of the returned module, use the dir function.
|
|
76
|
+
For example:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
protos = grpc.protos("foo.proto")
|
|
80
|
+
print(dir(protos))
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The returned module object corresponds to the _pb2.py file generated
|
|
84
|
+
by protoc. The path is expected to be relative to an entry on sys.path
|
|
85
|
+
and all transitive dependencies of the file should also be resolveable
|
|
86
|
+
from an entry on sys.path.
|
|
87
|
+
|
|
88
|
+
To completely disable the machinery behind this function, set the
|
|
89
|
+
GRPC_PYTHON_DISABLE_DYNAMIC_STUBS environment variable to "true".
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
protobuf_path: The path to the .proto file on the filesystem. This path
|
|
93
|
+
must be resolveable from an entry on sys.path and so must all of its
|
|
94
|
+
transitive dependencies.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
A module object corresponding to the message code for the indicated
|
|
98
|
+
.proto file. Equivalent to a generated _pb2.py file.
|
|
99
|
+
"""
|
|
100
|
+
return _call_with_lazy_import("protos", protobuf_path)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def services(protobuf_path): # pylint: disable=unused-argument
|
|
104
|
+
"""Returns a module generated by the indicated .proto file.
|
|
105
|
+
|
|
106
|
+
THIS IS AN EXPERIMENTAL API.
|
|
107
|
+
|
|
108
|
+
Use this function to retrieve classes and functions corresponding to
|
|
109
|
+
service definitions in the .proto file, including both stub and servicer
|
|
110
|
+
definitions.
|
|
111
|
+
|
|
112
|
+
To inspect the contents of the returned module, use the dir function.
|
|
113
|
+
For example:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
services = grpc.services("foo.proto")
|
|
117
|
+
print(dir(services))
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The returned module object corresponds to the _pb2_grpc.py file generated
|
|
121
|
+
by protoc. The path is expected to be relative to an entry on sys.path
|
|
122
|
+
and all transitive dependencies of the file should also be resolveable
|
|
123
|
+
from an entry on sys.path.
|
|
124
|
+
|
|
125
|
+
To completely disable the machinery behind this function, set the
|
|
126
|
+
GRPC_PYTHON_DISABLE_DYNAMIC_STUBS environment variable to "true".
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
protobuf_path: The path to the .proto file on the filesystem. This path
|
|
130
|
+
must be resolveable from an entry on sys.path and so must all of its
|
|
131
|
+
transitive dependencies.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
A module object corresponding to the stub/service code for the indicated
|
|
135
|
+
.proto file. Equivalent to a generated _pb2_grpc.py file.
|
|
136
|
+
"""
|
|
137
|
+
return _call_with_lazy_import("services", protobuf_path)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def protos_and_services(protobuf_path): # pylint: disable=unused-argument
|
|
141
|
+
"""Returns a 2-tuple of modules corresponding to protos and services.
|
|
142
|
+
|
|
143
|
+
THIS IS AN EXPERIMENTAL API.
|
|
144
|
+
|
|
145
|
+
The return value of this function is equivalent to a call to protos and a
|
|
146
|
+
call to services.
|
|
147
|
+
|
|
148
|
+
To completely disable the machinery behind this function, set the
|
|
149
|
+
GRPC_PYTHON_DISABLE_DYNAMIC_STUBS environment variable to "true".
|
|
150
|
+
|
|
151
|
+
Args:
|
|
152
|
+
protobuf_path: The path to the .proto file on the filesystem. This path
|
|
153
|
+
must be resolveable from an entry on sys.path and so must all of its
|
|
154
|
+
transitive dependencies.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
A 2-tuple of module objects corresponding to (protos(path), services(path)).
|
|
158
|
+
"""
|
|
159
|
+
return _call_with_lazy_import("protos_and_services", protobuf_path)
|