diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/grpc/src/python/grpcio | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/python/grpcio')
75 files changed, 4590 insertions, 4590 deletions
diff --git a/contrib/libs/grpc/src/python/grpcio/README.rst b/contrib/libs/grpc/src/python/grpcio/README.rst index fe34ad5adf..63651c1548 100644 --- a/contrib/libs/grpc/src/python/grpcio/README.rst +++ b/contrib/libs/grpc/src/python/grpcio/README.rst @@ -15,7 +15,7 @@ Python >= 3.5 Installation ------------ -gRPC Python is available for Linux, macOS, and Windows. +gRPC Python is available for Linux, macOS, and Windows. Installing From PyPI ~~~~~~~~~~~~~~~~~~~~ diff --git a/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py b/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py index 377cc7a9f3..a7f79f1e1e 100644 --- a/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py +++ b/contrib/libs/grpc/src/python/grpcio/_spawn_patch.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Patches the spawn() command for windows compilers. Windows has an 8191 character command line limit, but some compilers diff --git a/contrib/libs/grpc/src/python/grpcio/commands.py b/contrib/libs/grpc/src/python/grpcio/commands.py index 8240beb295..ef660a7458 100644 --- a/contrib/libs/grpc/src/python/grpcio/commands.py +++ b/contrib/libs/grpc/src/python/grpcio/commands.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Provides distutils command classes for the GRPC Python setup process.""" from __future__ import print_function @@ -76,8 +76,8 @@ def _get_grpc_custom_bdist(decorated_basename, target_bdist_basename): with open(bdist_path, 'w') as bdist_file: bdist_file.write(bdist_data) except IOError as error: - raise CommandError('{}\n\nCould not write grpcio bdist: {}'.format( - traceback.format_exc(), error.message)) + raise CommandError('{}\n\nCould not write grpcio bdist: {}'.format( + traceback.format_exc(), error.message)) return bdist_path @@ -206,7 +206,7 @@ class BuildExt(build_ext.build_ext): """Custom build_ext command to enable compiler-specific flags.""" C_OPTIONS = { - 'unix': ('-pthread',), + 'unix': ('-pthread',), 'msvc': (), } LINK_OPTIONS = {} @@ -238,7 +238,7 @@ class BuildExt(build_ext.build_ext): # for it. if not compiler_ok_with_extra_std(): old_compile = self.compiler._compile - + def new_compile(obj, src, ext, cc_args, extra_postargs, pp_opts): if src[-2:] == '.c': extra_postargs = [ diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/__init__.py index abe87458c4..8e15f3ac51 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/__init__.py @@ -1,16 +1,16 @@ -# Copyright 2015-2016 gRPC authors. +# Copyright 2015-2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """gRPC's Python API.""" import abc @@ -44,160 +44,160 @@ class FutureCancelledError(Exception): class Future(six.with_metaclass(abc.ABCMeta)): """A representation of a computation in another control flow. - Computations represented by a Future may be yet to be begun, - may be ongoing, or may have already completed. - """ + Computations represented by a Future may be yet to be begun, + may be ongoing, or may have already completed. + """ @abc.abstractmethod def cancel(self): """Attempts to cancel the computation. - This method does not block. + This method does not block. - Returns: - bool: - Returns True if the computation was canceled. + Returns: + bool: + Returns True if the computation was canceled. - Returns False under all other circumstances, for example: + Returns False under all other circumstances, for example: - 1. computation has begun and could not be canceled. - 2. computation has finished - 3. computation is scheduled for execution and it is impossible + 1. computation has begun and could not be canceled. + 2. computation has finished + 3. computation is scheduled for execution and it is impossible to determine its state without blocking. - """ + """ raise NotImplementedError() @abc.abstractmethod def cancelled(self): """Describes whether the computation was cancelled. - This method does not block. + This method does not block. - Returns: - bool: - Returns True if the computation was cancelled before its result became - available. + Returns: + bool: + Returns True if the computation was cancelled before its result became + available. Returns False under all other circumstances, for example: - 1. computation was not cancelled. - 2. computation's result is available. - """ + 1. computation was not cancelled. + 2. computation's result is available. + """ raise NotImplementedError() @abc.abstractmethod def running(self): """Describes whether the computation is taking place. - This method does not block. + This method does not block. - Returns: - Returns True if the computation is scheduled for execution or - currently executing. + Returns: + Returns True if the computation is scheduled for execution or + currently executing. - Returns False if the computation already executed or was cancelled. - """ + Returns False if the computation already executed or was cancelled. + """ raise NotImplementedError() @abc.abstractmethod def done(self): """Describes whether the computation has taken place. - This method does not block. + This method does not block. - Returns: - bool: - Returns True if the computation already executed or was cancelled. - Returns False if the computation is scheduled for execution or - currently executing. - This is exactly opposite of the running() method's result. - """ + Returns: + bool: + Returns True if the computation already executed or was cancelled. + Returns False if the computation is scheduled for execution or + currently executing. + This is exactly opposite of the running() method's result. + """ raise NotImplementedError() @abc.abstractmethod def result(self, timeout=None): - """Returns the result of the computation or raises its exception. + """Returns the result of the computation or raises its exception. - This method may return immediately or may block. + This method may return immediately or may block. - Args: - timeout: The length of time in seconds to wait for the computation to - finish or be cancelled. If None, the call will block until the - computations's termination. + Args: + timeout: The length of time in seconds to wait for the computation to + finish or be cancelled. If None, the call will block until the + computations's termination. - Returns: - The return value of the computation. + Returns: + The return value of the computation. - Raises: - FutureTimeoutError: If a timeout value is passed and the computation - does not terminate within the allotted time. - FutureCancelledError: If the computation was cancelled. - Exception: If the computation raised an exception, this call will - raise the same exception. - """ + Raises: + FutureTimeoutError: If a timeout value is passed and the computation + does not terminate within the allotted time. + FutureCancelledError: If the computation was cancelled. + Exception: If the computation raised an exception, this call will + raise the same exception. + """ raise NotImplementedError() @abc.abstractmethod def exception(self, timeout=None): """Return the exception raised by the computation. - This method may return immediately or may block. + This method may return immediately or may block. - Args: - timeout: The length of time in seconds to wait for the computation to - terminate or be cancelled. If None, the call will block until the - computations's termination. + Args: + timeout: The length of time in seconds to wait for the computation to + terminate or be cancelled. If None, the call will block until the + computations's termination. - Returns: - The exception raised by the computation, or None if the computation - did not raise an exception. + Returns: + The exception raised by the computation, or None if the computation + did not raise an exception. - Raises: - FutureTimeoutError: If a timeout value is passed and the computation - does not terminate within the allotted time. - FutureCancelledError: If the computation was cancelled. - """ + Raises: + FutureTimeoutError: If a timeout value is passed and the computation + does not terminate within the allotted time. + FutureCancelledError: If the computation was cancelled. + """ raise NotImplementedError() @abc.abstractmethod def traceback(self, timeout=None): """Access the traceback of the exception raised by the computation. - This method may return immediately or may block. + This method may return immediately or may block. - Args: - timeout: The length of time in seconds to wait for the computation - to terminate or be cancelled. If None, the call will block until - the computation's termination. + Args: + timeout: The length of time in seconds to wait for the computation + to terminate or be cancelled. If None, the call will block until + the computation's termination. - Returns: - The traceback of the exception raised by the computation, or None - if the computation did not raise an exception. + Returns: + The traceback of the exception raised by the computation, or None + if the computation did not raise an exception. - Raises: - FutureTimeoutError: If a timeout value is passed and the computation - does not terminate within the allotted time. - FutureCancelledError: If the computation was cancelled. - """ + Raises: + FutureTimeoutError: If a timeout value is passed and the computation + does not terminate within the allotted time. + FutureCancelledError: If the computation was cancelled. + """ raise NotImplementedError() @abc.abstractmethod def add_done_callback(self, fn): """Adds a function to be called at completion of the computation. - The callback will be passed this Future object describing the outcome - of the computation. Callbacks will be invoked after the future is + The callback will be passed this Future object describing the outcome + of the computation. Callbacks will be invoked after the future is terminated, whether successfully or not. - If the computation has already completed, the callback will be called - immediately. + If the computation has already completed, the callback will be called + immediately. Exceptions raised in the callback will be logged at ERROR level, but will not terminate any threads of execution. - Args: - fn: A callable taking this Future object as its single parameter. - """ + Args: + fn: A callable taking this Future object as its single parameter. + """ raise NotImplementedError() @@ -208,14 +208,14 @@ class Future(six.with_metaclass(abc.ABCMeta)): class ChannelConnectivity(enum.Enum): """Mirrors grpc_connectivity_state in the gRPC Core. - Attributes: - IDLE: The channel is idle. - CONNECTING: The channel is connecting. - READY: The channel is ready to conduct RPCs. - TRANSIENT_FAILURE: The channel has seen a failure from which it expects - to recover. - SHUTDOWN: The channel has seen a failure from which it cannot recover. - """ + Attributes: + IDLE: The channel is idle. + CONNECTING: The channel is connecting. + READY: The channel is ready to conduct RPCs. + TRANSIENT_FAILURE: The channel has seen a failure from which it expects + to recover. + SHUTDOWN: The channel has seen a failure from which it cannot recover. + """ IDLE = (_cygrpc.ConnectivityState.idle, 'idle') CONNECTING = (_cygrpc.ConnectivityState.connecting, 'connecting') READY = (_cygrpc.ConnectivityState.ready, 'ready') @@ -307,45 +307,45 @@ class RpcContext(six.with_metaclass(abc.ABCMeta)): @abc.abstractmethod def is_active(self): - """Describes whether the RPC is active or has terminated. - - Returns: - bool: - True if RPC is active, False otherwise. - """ + """Describes whether the RPC is active or has terminated. + + Returns: + bool: + True if RPC is active, False otherwise. + """ raise NotImplementedError() @abc.abstractmethod def time_remaining(self): """Describes the length of allowed time remaining for the RPC. - Returns: - A nonnegative float indicating the length of allowed time in seconds - remaining for the RPC to complete before it is considered to have - timed out, or None if no deadline was specified for the RPC. - """ + Returns: + A nonnegative float indicating the length of allowed time in seconds + remaining for the RPC to complete before it is considered to have + timed out, or None if no deadline was specified for the RPC. + """ raise NotImplementedError() @abc.abstractmethod def cancel(self): """Cancels the RPC. - Idempotent and has no effect if the RPC has already terminated. - """ + Idempotent and has no effect if the RPC has already terminated. + """ raise NotImplementedError() @abc.abstractmethod def add_callback(self, callback): """Registers a callback to be called on RPC termination. - Args: - callback: A no-parameter callable to be called on RPC termination. + Args: + callback: A no-parameter callable to be called on RPC termination. - Returns: + Returns: True if the callback was added and will be called later; False if - the callback was not added and will not be called (because the RPC - already terminated or some other reason). - """ + the callback was not added and will not be called (because the RPC + already terminated or some other reason). + """ raise NotImplementedError() @@ -357,244 +357,244 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): @abc.abstractmethod def initial_metadata(self): - """Accesses the initial metadata sent by the server. + """Accesses the initial metadata sent by the server. - This method blocks until the value is available. + This method blocks until the value is available. - Returns: - The initial :term:`metadata`. - """ + Returns: + The initial :term:`metadata`. + """ raise NotImplementedError() @abc.abstractmethod def trailing_metadata(self): - """Accesses the trailing metadata sent by the server. + """Accesses the trailing metadata sent by the server. - This method blocks until the value is available. + This method blocks until the value is available. - Returns: - The trailing :term:`metadata`. - """ + Returns: + The trailing :term:`metadata`. + """ raise NotImplementedError() @abc.abstractmethod def code(self): - """Accesses the status code sent by the server. + """Accesses the status code sent by the server. - This method blocks until the value is available. + This method blocks until the value is available. - Returns: - The StatusCode value for the RPC. - """ + Returns: + The StatusCode value for the RPC. + """ raise NotImplementedError() @abc.abstractmethod def details(self): - """Accesses the details sent by the server. - - This method blocks until the value is available. - - Returns: - The details string of the RPC. - """ - raise NotImplementedError() - - -############## Invocation-Side Interceptor Interfaces & Classes ############## - - -class ClientCallDetails(six.with_metaclass(abc.ABCMeta)): - """Describes an RPC to be invoked. - - This is an EXPERIMENTAL API. - - Attributes: - method: The method name of the RPC. - timeout: An optional duration of time in seconds to allow for the RPC. - metadata: Optional :term:`metadata` to be transmitted to - the service-side of the RPC. - credentials: An optional CallCredentials for the RPC. + """Accesses the details sent by the server. + + This method blocks until the value is available. + + Returns: + The details string of the RPC. + """ + raise NotImplementedError() + + +############## Invocation-Side Interceptor Interfaces & Classes ############## + + +class ClientCallDetails(six.with_metaclass(abc.ABCMeta)): + """Describes an RPC to be invoked. + + This is an EXPERIMENTAL API. + + Attributes: + method: The method name of the RPC. + timeout: An optional duration of time in seconds to allow for the RPC. + metadata: Optional :term:`metadata` to be transmitted to + the service-side of the RPC. + credentials: An optional CallCredentials for the RPC. wait_for_ready: This is an EXPERIMENTAL argument. An optional flag to enable :term:`wait_for_ready` mechanism. compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. """ - - -class UnaryUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)): - """Affords intercepting unary-unary invocations. - - This is an EXPERIMENTAL API. - """ - - @abc.abstractmethod - def intercept_unary_unary(self, continuation, client_call_details, request): - """Intercepts a unary-unary invocation asynchronously. - - Args: - continuation: A function that proceeds with the invocation by - executing the next interceptor in chain or invoking the - actual RPC on the underlying Channel. It is the interceptor's - responsibility to call it if it decides to move the RPC forward. - The interceptor can use - `response_future = continuation(client_call_details, request)` - to continue with the RPC. `continuation` returns an object that is - both a Call for the RPC and a Future. In the event of RPC - completion, the return Call-Future's result value will be - the response message of the RPC. Should the event terminate - with non-OK status, the returned Call-Future's exception value - will be an RpcError. - client_call_details: A ClientCallDetails object describing the - outgoing RPC. - request: The request value for the RPC. - - Returns: - An object that is both a Call for the RPC and a Future. - In the event of RPC completion, the return Call-Future's - result value will be the response message of the RPC. - Should the event terminate with non-OK status, the returned - Call-Future's exception value will be an RpcError. - """ - raise NotImplementedError() - - -class UnaryStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)): - """Affords intercepting unary-stream invocations. - - This is an EXPERIMENTAL API. - """ - - @abc.abstractmethod - def intercept_unary_stream(self, continuation, client_call_details, - request): - """Intercepts a unary-stream invocation. - - Args: - continuation: A function that proceeds with the invocation by - executing the next interceptor in chain or invoking the - actual RPC on the underlying Channel. It is the interceptor's - responsibility to call it if it decides to move the RPC forward. - The interceptor can use - `response_iterator = continuation(client_call_details, request)` - to continue with the RPC. `continuation` returns an object that is - both a Call for the RPC and an iterator for response values. - Drawing response values from the returned Call-iterator may - raise RpcError indicating termination of the RPC with non-OK - status. - client_call_details: A ClientCallDetails object describing the - outgoing RPC. - request: The request value for the RPC. - - Returns: - An object that is both a Call for the RPC and an iterator of - response values. Drawing response values from the returned - Call-iterator may raise RpcError indicating termination of - the RPC with non-OK status. - """ + + +class UnaryUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)): + """Affords intercepting unary-unary invocations. + + This is an EXPERIMENTAL API. + """ + + @abc.abstractmethod + def intercept_unary_unary(self, continuation, client_call_details, request): + """Intercepts a unary-unary invocation asynchronously. + + Args: + continuation: A function that proceeds with the invocation by + executing the next interceptor in chain or invoking the + actual RPC on the underlying Channel. It is the interceptor's + responsibility to call it if it decides to move the RPC forward. + The interceptor can use + `response_future = continuation(client_call_details, request)` + to continue with the RPC. `continuation` returns an object that is + both a Call for the RPC and a Future. In the event of RPC + completion, the return Call-Future's result value will be + the response message of the RPC. Should the event terminate + with non-OK status, the returned Call-Future's exception value + will be an RpcError. + client_call_details: A ClientCallDetails object describing the + outgoing RPC. + request: The request value for the RPC. + + Returns: + An object that is both a Call for the RPC and a Future. + In the event of RPC completion, the return Call-Future's + result value will be the response message of the RPC. + Should the event terminate with non-OK status, the returned + Call-Future's exception value will be an RpcError. + """ raise NotImplementedError() -class StreamUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)): - """Affords intercepting stream-unary invocations. - - This is an EXPERIMENTAL API. - """ - - @abc.abstractmethod - def intercept_stream_unary(self, continuation, client_call_details, - request_iterator): - """Intercepts a stream-unary invocation asynchronously. - - Args: - continuation: A function that proceeds with the invocation by - executing the next interceptor in chain or invoking the - actual RPC on the underlying Channel. It is the interceptor's - responsibility to call it if it decides to move the RPC forward. - The interceptor can use +class UnaryStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)): + """Affords intercepting unary-stream invocations. + + This is an EXPERIMENTAL API. + """ + + @abc.abstractmethod + def intercept_unary_stream(self, continuation, client_call_details, + request): + """Intercepts a unary-stream invocation. + + Args: + continuation: A function that proceeds with the invocation by + executing the next interceptor in chain or invoking the + actual RPC on the underlying Channel. It is the interceptor's + responsibility to call it if it decides to move the RPC forward. + The interceptor can use + `response_iterator = continuation(client_call_details, request)` + to continue with the RPC. `continuation` returns an object that is + both a Call for the RPC and an iterator for response values. + Drawing response values from the returned Call-iterator may + raise RpcError indicating termination of the RPC with non-OK + status. + client_call_details: A ClientCallDetails object describing the + outgoing RPC. + request: The request value for the RPC. + + Returns: + An object that is both a Call for the RPC and an iterator of + response values. Drawing response values from the returned + Call-iterator may raise RpcError indicating termination of + the RPC with non-OK status. + """ + raise NotImplementedError() + + +class StreamUnaryClientInterceptor(six.with_metaclass(abc.ABCMeta)): + """Affords intercepting stream-unary invocations. + + This is an EXPERIMENTAL API. + """ + + @abc.abstractmethod + def intercept_stream_unary(self, continuation, client_call_details, + request_iterator): + """Intercepts a stream-unary invocation asynchronously. + + Args: + continuation: A function that proceeds with the invocation by + executing the next interceptor in chain or invoking the + actual RPC on the underlying Channel. It is the interceptor's + responsibility to call it if it decides to move the RPC forward. + The interceptor can use `response_future = continuation(client_call_details, request_iterator)` - to continue with the RPC. `continuation` returns an object that is - both a Call for the RPC and a Future. In the event of RPC completion, - the return Call-Future's result value will be the response message - of the RPC. Should the event terminate with non-OK status, the - returned Call-Future's exception value will be an RpcError. - client_call_details: A ClientCallDetails object describing the - outgoing RPC. - request_iterator: An iterator that yields request values for the RPC. - - Returns: + to continue with the RPC. `continuation` returns an object that is + both a Call for the RPC and a Future. In the event of RPC completion, + the return Call-Future's result value will be the response message + of the RPC. Should the event terminate with non-OK status, the + returned Call-Future's exception value will be an RpcError. + client_call_details: A ClientCallDetails object describing the + outgoing RPC. + request_iterator: An iterator that yields request values for the RPC. + + Returns: An object that is both a Call for the RPC and a Future. In the event of RPC completion, the return Call-Future's result value will be the response message of the RPC. Should the event terminate with non-OK status, the returned Call-Future's exception value will be an RpcError. - """ - raise NotImplementedError() - - -class StreamStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)): - """Affords intercepting stream-stream invocations. - - This is an EXPERIMENTAL API. - """ - - @abc.abstractmethod - def intercept_stream_stream(self, continuation, client_call_details, - request_iterator): - """Intercepts a stream-stream invocation. - + """ + raise NotImplementedError() + + +class StreamStreamClientInterceptor(six.with_metaclass(abc.ABCMeta)): + """Affords intercepting stream-stream invocations. + + This is an EXPERIMENTAL API. + """ + + @abc.abstractmethod + def intercept_stream_stream(self, continuation, client_call_details, + request_iterator): + """Intercepts a stream-stream invocation. + Args: - continuation: A function that proceeds with the invocation by - executing the next interceptor in chain or invoking the - actual RPC on the underlying Channel. It is the interceptor's - responsibility to call it if it decides to move the RPC forward. - The interceptor can use + continuation: A function that proceeds with the invocation by + executing the next interceptor in chain or invoking the + actual RPC on the underlying Channel. It is the interceptor's + responsibility to call it if it decides to move the RPC forward. + The interceptor can use `response_iterator = continuation(client_call_details, request_iterator)` - to continue with the RPC. `continuation` returns an object that is - both a Call for the RPC and an iterator for response values. - Drawing response values from the returned Call-iterator may - raise RpcError indicating termination of the RPC with non-OK - status. - client_call_details: A ClientCallDetails object describing the - outgoing RPC. - request_iterator: An iterator that yields request values for the RPC. - - Returns: + to continue with the RPC. `continuation` returns an object that is + both a Call for the RPC and an iterator for response values. + Drawing response values from the returned Call-iterator may + raise RpcError indicating termination of the RPC with non-OK + status. + client_call_details: A ClientCallDetails object describing the + outgoing RPC. + request_iterator: An iterator that yields request values for the RPC. + + Returns: An object that is both a Call for the RPC and an iterator of response values. Drawing response values from the returned Call-iterator may raise RpcError indicating termination of the RPC with non-OK status. - """ - raise NotImplementedError() - - + """ + raise NotImplementedError() + + ############ Authentication & Authorization Interfaces & Classes ############# class ChannelCredentials(object): - """An encapsulation of the data required to create a secure Channel. + """An encapsulation of the data required to create a secure Channel. - This class has no supported interface - it exists to define the type of its - instances and its instances exist to be passed to other functions. For - example, ssl_channel_credentials returns an instance of this class and - secure_channel requires an instance of this class. - """ + This class has no supported interface - it exists to define the type of its + instances and its instances exist to be passed to other functions. For + example, ssl_channel_credentials returns an instance of this class and + secure_channel requires an instance of this class. + """ def __init__(self, credentials): self._credentials = credentials class CallCredentials(object): - """An encapsulation of the data required to assert an identity over a call. + """An encapsulation of the data required to assert an identity over a call. A CallCredentials has to be used with secure Channel, otherwise the metadata will not be transmitted to the server. - A CallCredentials may be composed with ChannelCredentials to always assert - identity for every call over that Channel. + A CallCredentials may be composed with ChannelCredentials to always assert + identity for every call over that Channel. - This class has no supported interface - it exists to define the type of its - instances and its instances exist to be passed to other functions. - """ + This class has no supported interface - it exists to define the type of its + instances and its instances exist to be passed to other functions. + """ def __init__(self, credentials): self._credentials = credentials @@ -603,22 +603,22 @@ class CallCredentials(object): class AuthMetadataContext(six.with_metaclass(abc.ABCMeta)): """Provides information to call credentials metadata plugins. - Attributes: - service_url: A string URL of the service being called into. - method_name: A string of the fully qualified method name being called. - """ + Attributes: + service_url: A string URL of the service being called into. + method_name: A string of the fully qualified method name being called. + """ class AuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)): """Callback object received by a metadata plugin.""" def __call__(self, metadata, error): - """Passes to the gRPC runtime authentication metadata for an RPC. + """Passes to the gRPC runtime authentication metadata for an RPC. - Args: - metadata: The :term:`metadata` used to construct the CallCredentials. - error: An Exception to indicate error or None to indicate success. - """ + Args: + metadata: The :term:`metadata` used to construct the CallCredentials. + error: An Exception to indicate error or None to indicate success. + """ raise NotImplementedError() @@ -630,46 +630,46 @@ class AuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)): This method will be invoked asynchronously in a separate thread. - Args: - context: An AuthMetadataContext providing information on the RPC that - the plugin is being called to authenticate. - callback: An AuthMetadataPluginCallback to be invoked either - synchronously or asynchronously. - """ + Args: + context: An AuthMetadataContext providing information on the RPC that + the plugin is being called to authenticate. + callback: An AuthMetadataPluginCallback to be invoked either + synchronously or asynchronously. + """ raise NotImplementedError() class ServerCredentials(object): - """An encapsulation of the data required to open a secure port on a Server. + """An encapsulation of the data required to open a secure port on a Server. - This class has no supported interface - it exists to define the type of its - instances and its instances exist to be passed to other functions. - """ + This class has no supported interface - it exists to define the type of its + instances and its instances exist to be passed to other functions. + """ def __init__(self, credentials): self._credentials = credentials -class ServerCertificateConfiguration(object): - """A certificate configuration for use with an SSL-enabled Server. - - Instances of this class can be returned in the certificate configuration - fetching callback. - - This class has no supported interface -- it exists to define the - type of its instances and its instances exist to be passed to - other functions. - """ - - def __init__(self, certificate_configuration): - self._certificate_configuration = certificate_configuration - - +class ServerCertificateConfiguration(object): + """A certificate configuration for use with an SSL-enabled Server. + + Instances of this class can be returned in the certificate configuration + fetching callback. + + This class has no supported interface -- it exists to define the + type of its instances and its instances exist to be passed to + other functions. + """ + + def __init__(self, certificate_configuration): + self._certificate_configuration = certificate_configuration + + ######################## Multi-Callable Interfaces ########################### class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): - """Affords invoking a unary-unary RPC from client-side.""" + """Affords invoking a unary-unary RPC from client-side.""" @abc.abstractmethod def __call__(self, @@ -681,12 +681,12 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression=None): """Synchronously invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: An optional duration of time in seconds to allow - for the RPC. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + Args: + request: The request value for the RPC. + timeout: An optional duration of time in seconds to allow + for the RPC. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -694,14 +694,14 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - The response value for the RPC. + Returns: + The response value for the RPC. - Raises: - RpcError: Indicating that the RPC terminated with non-OK status. The - raised RpcError will also be a Call for the RPC affording the RPC's - metadata, status code, and details. - """ + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also be a Call for the RPC affording the RPC's + metadata, status code, and details. + """ raise NotImplementedError() @abc.abstractmethod @@ -714,12 +714,12 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression=None): """Synchronously invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: An optional durating of time in seconds to allow for - the RPC. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + Args: + request: The request value for the RPC. + timeout: An optional durating of time in seconds to allow for + the RPC. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -727,14 +727,14 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - The response value for the RPC and a Call value for the RPC. + Returns: + The response value for the RPC and a Call value for the RPC. - Raises: - RpcError: Indicating that the RPC terminated with non-OK status. The - raised RpcError will also be a Call for the RPC affording the RPC's - metadata, status code, and details. - """ + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also be a Call for the RPC affording the RPC's + metadata, status code, and details. + """ raise NotImplementedError() @abc.abstractmethod @@ -747,12 +747,12 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression=None): """Asynchronously invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + Args: + request: The request value for the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -760,18 +760,18 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - An object that is both a Call for the RPC and a Future. - In the event of RPC completion, the return Call-Future's result - value will be the response message of the RPC. - Should the event terminate with non-OK status, - the returned Call-Future's exception value will be an RpcError. - """ + Returns: + An object that is both a Call for the RPC and a Future. + In the event of RPC completion, the return Call-Future's result + value will be the response message of the RPC. + Should the event terminate with non-OK status, + the returned Call-Future's exception value will be an RpcError. + """ raise NotImplementedError() class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): - """Affords invoking a unary-stream RPC from client-side.""" + """Affords invoking a unary-stream RPC from client-side.""" @abc.abstractmethod def __call__(self, @@ -783,12 +783,12 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): compression=None): """Invokes the underlying RPC. - Args: - request: The request value for the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. If None, the timeout is considered infinite. - metadata: An optional :term:`metadata` to be transmitted to the - service-side of the RPC. + Args: + request: The request value for the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. If None, the timeout is considered infinite. + metadata: An optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -796,17 +796,17 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - An object that is both a Call for the RPC and an iterator of - response values. Drawing response values from the returned - Call-iterator may raise RpcError indicating termination of the - RPC with non-OK status. - """ + Returns: + An object that is both a Call for the RPC and an iterator of + response values. Drawing response values from the returned + Call-iterator may raise RpcError indicating termination of the + RPC with non-OK status. + """ raise NotImplementedError() class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): - """Affords invoking a stream-unary RPC from client-side.""" + """Affords invoking a stream-unary RPC from client-side.""" @abc.abstractmethod def __call__(self, @@ -818,13 +818,13 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression=None): """Synchronously invokes the underlying RPC. - Args: - request_iterator: An iterator that yields request values for - the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. If None, the timeout is considered infinite. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + Args: + request_iterator: An iterator that yields request values for + the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. If None, the timeout is considered infinite. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -832,14 +832,14 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - The response value for the RPC. + Returns: + The response value for the RPC. - Raises: - RpcError: Indicating that the RPC terminated with non-OK status. The - raised RpcError will also implement grpc.Call, affording methods - such as metadata, code, and details. - """ + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also implement grpc.Call, affording methods + such as metadata, code, and details. + """ raise NotImplementedError() @abc.abstractmethod @@ -850,15 +850,15 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): credentials=None, wait_for_ready=None, compression=None): - """Synchronously invokes the underlying RPC on the client. - - Args: - request_iterator: An iterator that yields request values for - the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. If None, the timeout is considered infinite. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + """Synchronously invokes the underlying RPC on the client. + + Args: + request_iterator: An iterator that yields request values for + the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. If None, the timeout is considered infinite. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -866,14 +866,14 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - The response value for the RPC and a Call object for the RPC. + Returns: + The response value for the RPC and a Call object for the RPC. - Raises: - RpcError: Indicating that the RPC terminated with non-OK status. The - raised RpcError will also be a Call for the RPC affording the RPC's - metadata, status code, and details. - """ + Raises: + RpcError: Indicating that the RPC terminated with non-OK status. The + raised RpcError will also be a Call for the RPC affording the RPC's + metadata, status code, and details. + """ raise NotImplementedError() @abc.abstractmethod @@ -884,14 +884,14 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): credentials=None, wait_for_ready=None, compression=None): - """Asynchronously invokes the underlying RPC on the client. - - Args: - request_iterator: An iterator that yields request values for the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. If None, the timeout is considered infinite. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + """Asynchronously invokes the underlying RPC on the client. + + Args: + request_iterator: An iterator that yields request values for the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. If None, the timeout is considered infinite. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -899,18 +899,18 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - An object that is both a Call for the RPC and a Future. - In the event of RPC completion, the return Call-Future's result value - will be the response message of the RPC. Should the event terminate - with non-OK status, the returned Call-Future's exception value will - be an RpcError. - """ + Returns: + An object that is both a Call for the RPC and a Future. + In the event of RPC completion, the return Call-Future's result value + will be the response message of the RPC. Should the event terminate + with non-OK status, the returned Call-Future's exception value will + be an RpcError. + """ raise NotImplementedError() class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): - """Affords invoking a stream-stream RPC on client-side.""" + """Affords invoking a stream-stream RPC on client-side.""" @abc.abstractmethod def __call__(self, @@ -920,14 +920,14 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): credentials=None, wait_for_ready=None, compression=None): - """Invokes the underlying RPC on the client. - - Args: - request_iterator: An iterator that yields request values for the RPC. - timeout: An optional duration of time in seconds to allow for - the RPC. If not specified, the timeout is considered infinite. - metadata: Optional :term:`metadata` to be transmitted to the - service-side of the RPC. + """Invokes the underlying RPC on the client. + + Args: + request_iterator: An iterator that yields request values for the RPC. + timeout: An optional duration of time in seconds to allow for + the RPC. If not specified, the timeout is considered infinite. + metadata: Optional :term:`metadata` to be transmitted to the + service-side of the RPC. credentials: An optional CallCredentials for the RPC. Only valid for secure Channel. wait_for_ready: This is an EXPERIMENTAL argument. An optional @@ -935,12 +935,12 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This is an EXPERIMENTAL option. - Returns: - An object that is both a Call for the RPC and an iterator of - response values. Drawing response values from the returned - Call-iterator may raise RpcError indicating termination of the - RPC with non-OK status. - """ + Returns: + An object that is both a Call for the RPC and an iterator of + response values. Drawing response values from the returned + Call-iterator may raise RpcError indicating termination of the + RPC with non-OK status. + """ raise NotImplementedError() @@ -948,41 +948,41 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): class Channel(six.with_metaclass(abc.ABCMeta)): - """Affords RPC invocation via generic methods on client-side. - - Channel objects implement the Context Manager type, although they need not - support being entered and exited multiple times. - """ + """Affords RPC invocation via generic methods on client-side. + Channel objects implement the Context Manager type, although they need not + support being entered and exited multiple times. + """ + @abc.abstractmethod def subscribe(self, callback, try_to_connect=False): - """Subscribe to this Channel's connectivity state machine. - - A Channel may be in any of the states described by ChannelConnectivity. - This method allows application to monitor the state transitions. - The typical use case is to debug or gain better visibility into gRPC - runtime's state. - - Args: - callback: A callable to be invoked with ChannelConnectivity argument. - ChannelConnectivity describes current state of the channel. - The callable will be invoked immediately upon subscription - and again for every change to ChannelConnectivity until it - is unsubscribed or this Channel object goes out of scope. - try_to_connect: A boolean indicating whether or not this Channel - should attempt to connect immediately. If set to False, gRPC - runtime decides when to connect. - """ + """Subscribe to this Channel's connectivity state machine. + + A Channel may be in any of the states described by ChannelConnectivity. + This method allows application to monitor the state transitions. + The typical use case is to debug or gain better visibility into gRPC + runtime's state. + + Args: + callback: A callable to be invoked with ChannelConnectivity argument. + ChannelConnectivity describes current state of the channel. + The callable will be invoked immediately upon subscription + and again for every change to ChannelConnectivity until it + is unsubscribed or this Channel object goes out of scope. + try_to_connect: A boolean indicating whether or not this Channel + should attempt to connect immediately. If set to False, gRPC + runtime decides when to connect. + """ raise NotImplementedError() @abc.abstractmethod def unsubscribe(self, callback): - """Unsubscribes a subscribed callback from this Channel's connectivity. + """Unsubscribes a subscribed callback from this Channel's connectivity. - Args: - callback: A callable previously registered with this Channel from - having been passed to its "subscribe" method. - """ + Args: + callback: A callable previously registered with this Channel from + having been passed to its "subscribe" method. + """ raise NotImplementedError() @abc.abstractmethod @@ -992,17 +992,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)): response_deserializer=None): """Creates a UnaryUnaryMultiCallable for a unary-unary method. - Args: - method: The name of the RPC method. + Args: + method: The name of the RPC method. request_serializer: Optional :term:`serializer` for serializing the request - message. Request goes unserialized in case None is passed. + message. Request goes unserialized in case None is passed. response_deserializer: Optional :term:`deserializer` for deserializing the - response message. Response goes undeserialized in case None - is passed. + response message. Response goes undeserialized in case None + is passed. - Returns: - A UnaryUnaryMultiCallable value for the named unary-unary method. - """ + Returns: + A UnaryUnaryMultiCallable value for the named unary-unary method. + """ raise NotImplementedError() @abc.abstractmethod @@ -1012,17 +1012,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)): response_deserializer=None): """Creates a UnaryStreamMultiCallable for a unary-stream method. - Args: - method: The name of the RPC method. + Args: + method: The name of the RPC method. request_serializer: Optional :term:`serializer` for serializing the request - message. Request goes unserialized in case None is passed. + message. Request goes unserialized in case None is passed. response_deserializer: Optional :term:`deserializer` for deserializing the - response message. Response goes undeserialized in case None is - passed. + response message. Response goes undeserialized in case None is + passed. - Returns: - A UnaryStreamMultiCallable value for the name unary-stream method. - """ + Returns: + A UnaryStreamMultiCallable value for the name unary-stream method. + """ raise NotImplementedError() @abc.abstractmethod @@ -1032,17 +1032,17 @@ class Channel(six.with_metaclass(abc.ABCMeta)): response_deserializer=None): """Creates a StreamUnaryMultiCallable for a stream-unary method. - Args: - method: The name of the RPC method. + Args: + method: The name of the RPC method. request_serializer: Optional :term:`serializer` for serializing the request - message. Request goes unserialized in case None is passed. + message. Request goes unserialized in case None is passed. response_deserializer: Optional :term:`deserializer` for deserializing the - response message. Response goes undeserialized in case None is - passed. + response message. Response goes undeserialized in case None is + passed. - Returns: - A StreamUnaryMultiCallable value for the named stream-unary method. - """ + Returns: + A StreamUnaryMultiCallable value for the named stream-unary method. + """ raise NotImplementedError() @abc.abstractmethod @@ -1052,34 +1052,34 @@ class Channel(six.with_metaclass(abc.ABCMeta)): response_deserializer=None): """Creates a StreamStreamMultiCallable for a stream-stream method. - Args: - method: The name of the RPC method. + Args: + method: The name of the RPC method. request_serializer: Optional :term:`serializer` for serializing the request - message. Request goes unserialized in case None is passed. + message. Request goes unserialized in case None is passed. response_deserializer: Optional :term:`deserializer` for deserializing the - response message. Response goes undeserialized in case None - is passed. + response message. Response goes undeserialized in case None + is passed. - Returns: - A StreamStreamMultiCallable value for the named stream-stream method. - """ - raise NotImplementedError() - - @abc.abstractmethod - def close(self): - """Closes this Channel and releases all resources held by it. - - Closing the Channel will immediately terminate all RPCs active with the - Channel and it is not valid to invoke new RPCs with the Channel. - - This method is idempotent. - """ + Returns: + A StreamStreamMultiCallable value for the named stream-stream method. + """ raise NotImplementedError() + @abc.abstractmethod + def close(self): + """Closes this Channel and releases all resources held by it. + + Closing the Channel will immediately terminate all RPCs active with the + Channel and it is not valid to invoke new RPCs with the Channel. + + This method is idempotent. + """ + raise NotImplementedError() + def __enter__(self): """Enters the runtime context related to the channel object.""" raise NotImplementedError() - + def __exit__(self, exc_type, exc_val, exc_tb): """Exits the runtime context related to the channel object.""" raise NotImplementedError() @@ -1093,58 +1093,58 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): @abc.abstractmethod def invocation_metadata(self): - """Accesses the metadata from the sent by the client. + """Accesses the metadata from the sent by the client. - Returns: - The invocation :term:`metadata`. - """ + Returns: + The invocation :term:`metadata`. + """ raise NotImplementedError() @abc.abstractmethod def peer(self): """Identifies the peer that invoked the RPC being serviced. - Returns: - A string identifying the peer that invoked the RPC being serviced. - The string format is determined by gRPC runtime. - """ + Returns: + A string identifying the peer that invoked the RPC being serviced. + The string format is determined by gRPC runtime. + """ raise NotImplementedError() @abc.abstractmethod - def peer_identities(self): - """Gets one or more peer identity(s). - - Equivalent to + def peer_identities(self): + """Gets one or more peer identity(s). + + Equivalent to servicer_context.auth_context().get(servicer_context.peer_identity_key()) - - Returns: - An iterable of the identities, or None if the call is not - authenticated. Each identity is returned as a raw bytes type. - """ - raise NotImplementedError() - - @abc.abstractmethod - def peer_identity_key(self): - """The auth property used to identify the peer. - - For example, "x509_common_name" or "x509_subject_alternative_name" are - used to identify an SSL peer. - - Returns: - The auth property (string) that indicates the - peer identity, or None if the call is not authenticated. - """ - raise NotImplementedError() - - @abc.abstractmethod - def auth_context(self): - """Gets the auth context for the call. - - Returns: - A map of strings to an iterable of bytes for each auth property. - """ - raise NotImplementedError() - + + Returns: + An iterable of the identities, or None if the call is not + authenticated. Each identity is returned as a raw bytes type. + """ + raise NotImplementedError() + + @abc.abstractmethod + def peer_identity_key(self): + """The auth property used to identify the peer. + + For example, "x509_common_name" or "x509_subject_alternative_name" are + used to identify an SSL peer. + + Returns: + The auth property (string) that indicates the + peer identity, or None if the call is not authenticated. + """ + raise NotImplementedError() + + @abc.abstractmethod + def auth_context(self): + """Gets the auth context for the call. + + Returns: + A map of strings to an iterable of bytes for each auth property. + """ + raise NotImplementedError() + def set_compression(self, compression): """Set the compression algorithm to be used for the entire call. @@ -1156,16 +1156,16 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): """ raise NotImplementedError() - @abc.abstractmethod + @abc.abstractmethod def send_initial_metadata(self, initial_metadata): - """Sends the initial metadata value to the client. + """Sends the initial metadata value to the client. - This method need not be called by implementations if they have no - metadata to add to what the gRPC runtime will transmit. + This method need not be called by implementations if they have no + metadata to add to what the gRPC runtime will transmit. - Args: - initial_metadata: The initial :term:`metadata`. - """ + Args: + initial_metadata: The initial :term:`metadata`. + """ raise NotImplementedError() @abc.abstractmethod @@ -1178,34 +1178,34 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): RPC, the value supplied in the final invocation will be the value sent over the wire. - This method need not be called by implementations if they have no - metadata to add to what the gRPC runtime will transmit. + This method need not be called by implementations if they have no + metadata to add to what the gRPC runtime will transmit. - Args: - trailing_metadata: The trailing :term:`metadata`. - """ + Args: + trailing_metadata: The trailing :term:`metadata`. + """ raise NotImplementedError() @abc.abstractmethod - def abort(self, code, details): - """Raises an exception to terminate the RPC with a non-OK status. - - The code and details passed as arguments will supercede any existing - ones. - - Args: - code: A StatusCode object to be sent to the client. - It must not be StatusCode.OK. + def abort(self, code, details): + """Raises an exception to terminate the RPC with a non-OK status. + + The code and details passed as arguments will supercede any existing + ones. + + Args: + code: A StatusCode object to be sent to the client. + It must not be StatusCode.OK. details: A UTF-8-encodable string to be sent to the client upon - termination of the RPC. - - Raises: - Exception: An exception is always raised to signal the abortion the - RPC to the gRPC runtime. - """ - raise NotImplementedError() - - @abc.abstractmethod + termination of the RPC. + + Raises: + Exception: An exception is always raised to signal the abortion the + RPC to the gRPC runtime. + """ + raise NotImplementedError() + + @abc.abstractmethod def abort_with_status(self, status): """Raises an exception to terminate the RPC with a non-OK status. @@ -1226,27 +1226,27 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): @abc.abstractmethod def set_code(self, code): - """Sets the value to be used as status code upon RPC completion. + """Sets the value to be used as status code upon RPC completion. - This method need not be called by method implementations if they wish - the gRPC runtime to determine the status code of the RPC. + This method need not be called by method implementations if they wish + the gRPC runtime to determine the status code of the RPC. - Args: - code: A StatusCode object to be sent to the client. - """ + Args: + code: A StatusCode object to be sent to the client. + """ raise NotImplementedError() @abc.abstractmethod def set_details(self, details): - """Sets the value to be used as detail string upon RPC completion. + """Sets the value to be used as detail string upon RPC completion. - This method need not be called by method implementations if they have - no details to transmit. + This method need not be called by method implementations if they have + no details to transmit. - Args: + Args: details: A UTF-8-encodable string to be sent to the client upon - termination of the RPC. - """ + termination of the RPC. + """ raise NotImplementedError() def disable_next_message_compression(self): @@ -1266,46 +1266,46 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): class RpcMethodHandler(six.with_metaclass(abc.ABCMeta)): """An implementation of a single RPC method. - Attributes: - request_streaming: Whether the RPC supports exactly one request message - or any arbitrary number of request messages. - response_streaming: Whether the RPC supports exactly one response message - or any arbitrary number of response messages. + Attributes: + request_streaming: Whether the RPC supports exactly one request message + or any arbitrary number of request messages. + response_streaming: Whether the RPC supports exactly one response message + or any arbitrary number of response messages. request_deserializer: A callable :term:`deserializer` that accepts a byte string and - returns an object suitable to be passed to this object's business - logic, or None to indicate that this object's business logic should be - passed the raw request bytes. + returns an object suitable to be passed to this object's business + logic, or None to indicate that this object's business logic should be + passed the raw request bytes. response_serializer: A callable :term:`serializer` that accepts an object produced - by this object's business logic and returns a byte string, or None to - indicate that the byte strings produced by this object's business logic - should be transmitted on the wire as they are. - unary_unary: This object's application-specific business logic as a - callable value that takes a request value and a ServicerContext object - and returns a response value. Only non-None if both request_streaming - and response_streaming are False. - unary_stream: This object's application-specific business logic as a - callable value that takes a request value and a ServicerContext object - and returns an iterator of response values. Only non-None if - request_streaming is False and response_streaming is True. - stream_unary: This object's application-specific business logic as a - callable value that takes an iterator of request values and a - ServicerContext object and returns a response value. Only non-None if - request_streaming is True and response_streaming is False. - stream_stream: This object's application-specific business logic as a - callable value that takes an iterator of request values and a - ServicerContext object and returns an iterator of response values. - Only non-None if request_streaming and response_streaming are both - True. - """ + by this object's business logic and returns a byte string, or None to + indicate that the byte strings produced by this object's business logic + should be transmitted on the wire as they are. + unary_unary: This object's application-specific business logic as a + callable value that takes a request value and a ServicerContext object + and returns a response value. Only non-None if both request_streaming + and response_streaming are False. + unary_stream: This object's application-specific business logic as a + callable value that takes a request value and a ServicerContext object + and returns an iterator of response values. Only non-None if + request_streaming is False and response_streaming is True. + stream_unary: This object's application-specific business logic as a + callable value that takes an iterator of request values and a + ServicerContext object and returns a response value. Only non-None if + request_streaming is True and response_streaming is False. + stream_stream: This object's application-specific business logic as a + callable value that takes an iterator of request values and a + ServicerContext object and returns an iterator of response values. + Only non-None if request_streaming and response_streaming are both + True. + """ class HandlerCallDetails(six.with_metaclass(abc.ABCMeta)): """Describes an RPC that has just arrived for service. - Attributes: - method: The method name of the RPC. - invocation_metadata: The :term:`metadata` sent by the client. - """ + Attributes: + method: The method name of the RPC. + invocation_metadata: The :term:`metadata` sent by the client. + """ class GenericRpcHandler(six.with_metaclass(abc.ABCMeta)): @@ -1313,63 +1313,63 @@ class GenericRpcHandler(six.with_metaclass(abc.ABCMeta)): @abc.abstractmethod def service(self, handler_call_details): - """Returns the handler for servicing the RPC. + """Returns the handler for servicing the RPC. - Args: - handler_call_details: A HandlerCallDetails describing the RPC. + Args: + handler_call_details: A HandlerCallDetails describing the RPC. - Returns: - An RpcMethodHandler with which the RPC may be serviced if the - implementation chooses to service this RPC, or None otherwise. - """ + Returns: + An RpcMethodHandler with which the RPC may be serviced if the + implementation chooses to service this RPC, or None otherwise. + """ raise NotImplementedError() class ServiceRpcHandler(six.with_metaclass(abc.ABCMeta, GenericRpcHandler)): """An implementation of RPC methods belonging to a service. - A service handles RPC methods with structured names of the form - '/Service.Name/Service.Method', where 'Service.Name' is the value - returned by service_name(), and 'Service.Method' is the method - name. A service can have multiple method names, but only a single - service name. - """ + A service handles RPC methods with structured names of the form + '/Service.Name/Service.Method', where 'Service.Name' is the value + returned by service_name(), and 'Service.Method' is the method + name. A service can have multiple method names, but only a single + service name. + """ @abc.abstractmethod def service_name(self): - """Returns this service's name. - - Returns: - The service name. - """ - raise NotImplementedError() - - -#################### Service-Side Interceptor Interfaces ##################### - - -class ServerInterceptor(six.with_metaclass(abc.ABCMeta)): - """Affords intercepting incoming RPCs on the service-side. - - This is an EXPERIMENTAL API. + """Returns this service's name. + + Returns: + The service name. + """ + raise NotImplementedError() + + +#################### Service-Side Interceptor Interfaces ##################### + + +class ServerInterceptor(six.with_metaclass(abc.ABCMeta)): + """Affords intercepting incoming RPCs on the service-side. + + This is an EXPERIMENTAL API. """ - - @abc.abstractmethod - def intercept_service(self, continuation, handler_call_details): - """Intercepts incoming RPCs before handing them over to a handler. - - Args: - continuation: A function that takes a HandlerCallDetails and - proceeds to invoke the next interceptor in the chain, if any, - or the RPC handler lookup logic, with the call details passed - as an argument, and returns an RpcMethodHandler instance if - the RPC is considered serviced, or None otherwise. - handler_call_details: A HandlerCallDetails describing the RPC. - - Returns: - An RpcMethodHandler with which the RPC may be serviced if the - interceptor chooses to service this RPC, or None otherwise. - """ + + @abc.abstractmethod + def intercept_service(self, continuation, handler_call_details): + """Intercepts incoming RPCs before handing them over to a handler. + + Args: + continuation: A function that takes a HandlerCallDetails and + proceeds to invoke the next interceptor in the chain, if any, + or the RPC handler lookup logic, with the call details passed + as an argument, and returns an RpcMethodHandler instance if + the RPC is considered serviced, or None otherwise. + handler_call_details: A HandlerCallDetails describing the RPC. + + Returns: + An RpcMethodHandler with which the RPC may be serviced if the + interceptor chooses to service this RPC, or None otherwise. + """ raise NotImplementedError() @@ -1383,67 +1383,67 @@ class Server(six.with_metaclass(abc.ABCMeta)): def add_generic_rpc_handlers(self, generic_rpc_handlers): """Registers GenericRpcHandlers with this Server. - This method is only safe to call before the server is started. + This method is only safe to call before the server is started. - Args: - generic_rpc_handlers: An iterable of GenericRpcHandlers that will be - used to service RPCs. - """ + Args: + generic_rpc_handlers: An iterable of GenericRpcHandlers that will be + used to service RPCs. + """ raise NotImplementedError() @abc.abstractmethod def add_insecure_port(self, address): - """Opens an insecure port for accepting RPCs. + """Opens an insecure port for accepting RPCs. - This method may only be called before starting the server. + This method may only be called before starting the server. - Args: + Args: address: The address for which to open a port. If the port is 0, or not specified in the address, then gRPC runtime will choose a port. - Returns: - An integer port on which server will accept RPC requests. - """ + Returns: + An integer port on which server will accept RPC requests. + """ raise NotImplementedError() @abc.abstractmethod def add_secure_port(self, address, server_credentials): - """Opens a secure port for accepting RPCs. + """Opens a secure port for accepting RPCs. - This method may only be called before starting the server. + This method may only be called before starting the server. - Args: - address: The address for which to open a port. - if the port is 0, or not specified in the address, then gRPC - runtime will choose a port. - server_credentials: A ServerCredentials object. + Args: + address: The address for which to open a port. + if the port is 0, or not specified in the address, then gRPC + runtime will choose a port. + server_credentials: A ServerCredentials object. - Returns: - An integer port on which server will accept RPC requests. - """ + Returns: + An integer port on which server will accept RPC requests. + """ raise NotImplementedError() @abc.abstractmethod def start(self): - """Starts this Server. + """Starts this Server. - This method may only be called once. (i.e. it is not idempotent). - """ + This method may only be called once. (i.e. it is not idempotent). + """ raise NotImplementedError() @abc.abstractmethod def stop(self, grace): - """Stops this Server. + """Stops this Server. - This method immediately stop service of new RPCs in all cases. + This method immediately stop service of new RPCs in all cases. - If a grace period is specified, this method returns immediately - and all RPCs active at the end of the grace period are aborted. + If a grace period is specified, this method returns immediately + and all RPCs active at the end of the grace period are aborted. If a grace period is not specified (by passing None for `grace`), all existing RPCs are aborted immediately and this method blocks until the last RPC handler terminates. - This method is idempotent and may be called at any time. + This method is idempotent and may be called at any time. Passing a smaller grace value in a subsequent call will have the effect of stopping the Server sooner (passing None will have the effect of stopping the server immediately). Passing @@ -1451,14 +1451,14 @@ class Server(six.with_metaclass(abc.ABCMeta)): effect of stopping the server later (i.e. the most restrictive grace value is used). - Args: - grace: A duration of time in seconds or None. + Args: + grace: A duration of time in seconds or None. - Returns: - A threading.Event that will be set when this Server has completely - stopped, i.e. when running RPCs either complete or are aborted and - all handlers have terminated. - """ + Returns: + A threading.Event that will be set when this Server has completely + stopped, i.e. when running RPCs either complete or are aborted and + all handlers have terminated. + """ raise NotImplementedError() def wait_for_termination(self, timeout=None): @@ -1493,16 +1493,16 @@ def unary_unary_rpc_method_handler(behavior, response_serializer=None): """Creates an RpcMethodHandler for a unary-unary RPC method. - Args: - behavior: The implementation of an RPC that accepts one request - and returns one response. + Args: + behavior: The implementation of an RPC that accepts one request + and returns one response. request_deserializer: An optional :term:`deserializer` for request deserialization. response_serializer: An optional :term:`serializer` for response serialization. - Returns: - An RpcMethodHandler object that is typically used by grpc.Server. - """ - from grpc import _utilities # pylint: disable=cyclic-import + Returns: + An RpcMethodHandler object that is typically used by grpc.Server. + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.RpcMethodHandler(False, False, request_deserializer, response_serializer, behavior, None, None, None) @@ -1513,16 +1513,16 @@ def unary_stream_rpc_method_handler(behavior, response_serializer=None): """Creates an RpcMethodHandler for a unary-stream RPC method. - Args: - behavior: The implementation of an RPC that accepts one request - and returns an iterator of response values. + Args: + behavior: The implementation of an RPC that accepts one request + and returns an iterator of response values. request_deserializer: An optional :term:`deserializer` for request deserialization. response_serializer: An optional :term:`serializer` for response serialization. - Returns: - An RpcMethodHandler object that is typically used by grpc.Server. - """ - from grpc import _utilities # pylint: disable=cyclic-import + Returns: + An RpcMethodHandler object that is typically used by grpc.Server. + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.RpcMethodHandler(False, True, request_deserializer, response_serializer, None, behavior, None, None) @@ -1533,16 +1533,16 @@ def stream_unary_rpc_method_handler(behavior, response_serializer=None): """Creates an RpcMethodHandler for a stream-unary RPC method. - Args: - behavior: The implementation of an RPC that accepts an iterator of - request values and returns a single response value. + Args: + behavior: The implementation of an RPC that accepts an iterator of + request values and returns a single response value. request_deserializer: An optional :term:`deserializer` for request deserialization. response_serializer: An optional :term:`serializer` for response serialization. - Returns: - An RpcMethodHandler object that is typically used by grpc.Server. - """ - from grpc import _utilities # pylint: disable=cyclic-import + Returns: + An RpcMethodHandler object that is typically used by grpc.Server. + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.RpcMethodHandler(True, False, request_deserializer, response_serializer, None, None, behavior, None) @@ -1553,35 +1553,35 @@ def stream_stream_rpc_method_handler(behavior, response_serializer=None): """Creates an RpcMethodHandler for a stream-stream RPC method. - Args: - behavior: The implementation of an RPC that accepts an iterator of - request values and returns an iterator of response values. + Args: + behavior: The implementation of an RPC that accepts an iterator of + request values and returns an iterator of response values. request_deserializer: An optional :term:`deserializer` for request deserialization. response_serializer: An optional :term:`serializer` for response serialization. - Returns: - An RpcMethodHandler object that is typically used by grpc.Server. - """ - from grpc import _utilities # pylint: disable=cyclic-import + Returns: + An RpcMethodHandler object that is typically used by grpc.Server. + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.RpcMethodHandler(True, True, request_deserializer, response_serializer, None, None, None, behavior) def method_handlers_generic_handler(service, method_handlers): - """Creates a GenericRpcHandler from RpcMethodHandlers. - - Args: - service: The name of the service that is implemented by the - method_handlers. - method_handlers: A dictionary that maps method names to corresponding - RpcMethodHandler. - - Returns: - A GenericRpcHandler. This is typically added to the grpc.Server object - with add_generic_rpc_handlers() before starting the server. - """ - from grpc import _utilities # pylint: disable=cyclic-import + """Creates a GenericRpcHandler from RpcMethodHandlers. + + Args: + service: The name of the service that is implemented by the + method_handlers. + method_handlers: A dictionary that maps method names to corresponding + RpcMethodHandler. + + Returns: + A GenericRpcHandler. This is typically added to the grpc.Server object + with add_generic_rpc_handlers() before starting the server. + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.DictionaryGenericHandler(service, method_handlers) @@ -1590,86 +1590,86 @@ def ssl_channel_credentials(root_certificates=None, certificate_chain=None): """Creates a ChannelCredentials for use with an SSL-enabled Channel. - Args: - root_certificates: The PEM-encoded root certificates as a byte string, - or None to retrieve them from a default location chosen by gRPC - runtime. - private_key: The PEM-encoded private key as a byte string, or None if no - private key should be used. - certificate_chain: The PEM-encoded certificate chain as a byte string + Args: + root_certificates: The PEM-encoded root certificates as a byte string, + or None to retrieve them from a default location chosen by gRPC + runtime. + private_key: The PEM-encoded private key as a byte string, or None if no + private key should be used. + certificate_chain: The PEM-encoded certificate chain as a byte string to use or None if no certificate chain should be used. - Returns: - A ChannelCredentials for use with an SSL-enabled Channel. - """ + Returns: + A ChannelCredentials for use with an SSL-enabled Channel. + """ return ChannelCredentials( - _cygrpc.SSLChannelCredentials(root_certificates, private_key, - certificate_chain)) + _cygrpc.SSLChannelCredentials(root_certificates, private_key, + certificate_chain)) def metadata_call_credentials(metadata_plugin, name=None): """Construct CallCredentials from an AuthMetadataPlugin. - Args: - metadata_plugin: An AuthMetadataPlugin to use for authentication. - name: An optional name for the plugin. + Args: + metadata_plugin: An AuthMetadataPlugin to use for authentication. + name: An optional name for the plugin. - Returns: - A CallCredentials. - """ - from grpc import _plugin_wrapping # pylint: disable=cyclic-import - return _plugin_wrapping.metadata_plugin_call_credentials( - metadata_plugin, name) + Returns: + A CallCredentials. + """ + from grpc import _plugin_wrapping # pylint: disable=cyclic-import + return _plugin_wrapping.metadata_plugin_call_credentials( + metadata_plugin, name) def access_token_call_credentials(access_token): """Construct CallCredentials from an access token. - Args: - access_token: A string to place directly in the http request - authorization header, for example - "authorization: Bearer <access_token>". + Args: + access_token: A string to place directly in the http request + authorization header, for example + "authorization: Bearer <access_token>". - Returns: - A CallCredentials. - """ - from grpc import _auth # pylint: disable=cyclic-import - from grpc import _plugin_wrapping # pylint: disable=cyclic-import - return _plugin_wrapping.metadata_plugin_call_credentials( - _auth.AccessTokenAuthMetadataPlugin(access_token), None) + Returns: + A CallCredentials. + """ + from grpc import _auth # pylint: disable=cyclic-import + from grpc import _plugin_wrapping # pylint: disable=cyclic-import + return _plugin_wrapping.metadata_plugin_call_credentials( + _auth.AccessTokenAuthMetadataPlugin(access_token), None) def composite_call_credentials(*call_credentials): """Compose multiple CallCredentials to make a new CallCredentials. - Args: - *call_credentials: At least two CallCredentials objects. + Args: + *call_credentials: At least two CallCredentials objects. - Returns: - A CallCredentials object composed of the given CallCredentials objects. - """ + Returns: + A CallCredentials object composed of the given CallCredentials objects. + """ return CallCredentials( - _cygrpc.CompositeCallCredentials( - tuple(single_call_credentials._credentials - for single_call_credentials in call_credentials))) + _cygrpc.CompositeCallCredentials( + tuple(single_call_credentials._credentials + for single_call_credentials in call_credentials))) def composite_channel_credentials(channel_credentials, *call_credentials): """Compose a ChannelCredentials and one or more CallCredentials objects. - Args: - channel_credentials: A ChannelCredentials object. - *call_credentials: One or more CallCredentials objects. + Args: + channel_credentials: A ChannelCredentials object. + *call_credentials: One or more CallCredentials objects. - Returns: - A ChannelCredentials composed of the given ChannelCredentials and - CallCredentials objects. - """ + Returns: + A ChannelCredentials composed of the given ChannelCredentials and + CallCredentials objects. + """ return ChannelCredentials( - _cygrpc.CompositeChannelCredentials( - tuple(single_call_credentials._credentials - for single_call_credentials in call_credentials), - channel_credentials._credentials)) + _cygrpc.CompositeChannelCredentials( + tuple(single_call_credentials._credentials + for single_call_credentials in call_credentials), + channel_credentials._credentials)) def ssl_server_credentials(private_key_certificate_chain_pairs, @@ -1677,20 +1677,20 @@ def ssl_server_credentials(private_key_certificate_chain_pairs, require_client_auth=False): """Creates a ServerCredentials for use with an SSL-enabled Server. - Args: - private_key_certificate_chain_pairs: A list of pairs of the form - [PEM-encoded private key, PEM-encoded certificate chain]. - root_certificates: An optional byte string of PEM-encoded client root - certificates that the server will use to verify client authentication. - If omitted, require_client_auth must also be False. - require_client_auth: A boolean indicating whether or not to require - clients to be authenticated. May only be True if root_certificates - is not None. - - Returns: - A ServerCredentials for use with an SSL-enabled Server. Typically, this - object is an argument to add_secure_port() method during server setup. - """ + Args: + private_key_certificate_chain_pairs: A list of pairs of the form + [PEM-encoded private key, PEM-encoded certificate chain]. + root_certificates: An optional byte string of PEM-encoded client root + certificates that the server will use to verify client authentication. + If omitted, require_client_auth must also be False. + require_client_auth: A boolean indicating whether or not to require + clients to be authenticated. May only be True if root_certificates + is not None. + + Returns: + A ServerCredentials for use with an SSL-enabled Server. Typically, this + object is an argument to add_secure_port() method during server setup. + """ if not private_key_certificate_chain_pairs: raise ValueError( 'At least one private key-certificate chain pair is required!') @@ -1706,61 +1706,61 @@ def ssl_server_credentials(private_key_certificate_chain_pairs, ], require_client_auth)) -def ssl_server_certificate_configuration(private_key_certificate_chain_pairs, - root_certificates=None): - """Creates a ServerCertificateConfiguration for use with a Server. - - Args: - private_key_certificate_chain_pairs: A collection of pairs of - the form [PEM-encoded private key, PEM-encoded certificate - chain]. - root_certificates: An optional byte string of PEM-encoded client root - certificates that the server will use to verify client authentication. - - Returns: - A ServerCertificateConfiguration that can be returned in the certificate - configuration fetching callback. - """ +def ssl_server_certificate_configuration(private_key_certificate_chain_pairs, + root_certificates=None): + """Creates a ServerCertificateConfiguration for use with a Server. + + Args: + private_key_certificate_chain_pairs: A collection of pairs of + the form [PEM-encoded private key, PEM-encoded certificate + chain]. + root_certificates: An optional byte string of PEM-encoded client root + certificates that the server will use to verify client authentication. + + Returns: + A ServerCertificateConfiguration that can be returned in the certificate + configuration fetching callback. + """ if private_key_certificate_chain_pairs: - return ServerCertificateConfiguration( - _cygrpc.server_certificate_config_ssl(root_certificates, [ - _cygrpc.SslPemKeyCertPair(key, pem) - for key, pem in private_key_certificate_chain_pairs - ])) + return ServerCertificateConfiguration( + _cygrpc.server_certificate_config_ssl(root_certificates, [ + _cygrpc.SslPemKeyCertPair(key, pem) + for key, pem in private_key_certificate_chain_pairs + ])) else: raise ValueError( 'At least one private key-certificate chain pair is required!') - - -def dynamic_ssl_server_credentials(initial_certificate_configuration, - certificate_configuration_fetcher, - require_client_authentication=False): - """Creates a ServerCredentials for use with an SSL-enabled Server. - - Args: - initial_certificate_configuration (ServerCertificateConfiguration): The - certificate configuration with which the server will be initialized. - certificate_configuration_fetcher (callable): A callable that takes no - arguments and should return a ServerCertificateConfiguration to - replace the server's current certificate, or None for no change - (i.e., the server will continue its current certificate - config). The library will call this callback on *every* new - client connection before starting the TLS handshake with the - client, thus allowing the user application to optionally - return a new ServerCertificateConfiguration that the server will then - use for the handshake. - require_client_authentication: A boolean indicating whether or not to - require clients to be authenticated. - - Returns: - A ServerCredentials. - """ - return ServerCredentials( - _cygrpc.server_credentials_ssl_dynamic_cert_config( - initial_certificate_configuration, - certificate_configuration_fetcher, require_client_authentication)) - - + + +def dynamic_ssl_server_credentials(initial_certificate_configuration, + certificate_configuration_fetcher, + require_client_authentication=False): + """Creates a ServerCredentials for use with an SSL-enabled Server. + + Args: + initial_certificate_configuration (ServerCertificateConfiguration): The + certificate configuration with which the server will be initialized. + certificate_configuration_fetcher (callable): A callable that takes no + arguments and should return a ServerCertificateConfiguration to + replace the server's current certificate, or None for no change + (i.e., the server will continue its current certificate + config). The library will call this callback on *every* new + client connection before starting the TLS handshake with the + client, thus allowing the user application to optionally + return a new ServerCertificateConfiguration that the server will then + use for the handshake. + require_client_authentication: A boolean indicating whether or not to + require clients to be authenticated. + + Returns: + A ServerCredentials. + """ + return ServerCredentials( + _cygrpc.server_credentials_ssl_dynamic_cert_config( + initial_certificate_configuration, + certificate_configuration_fetcher, require_client_authentication)) + + @enum.unique class LocalConnectionType(enum.Enum): """Types of local connection for local credential creation. @@ -1886,19 +1886,19 @@ def compute_engine_channel_credentials(call_credentials): def channel_ready_future(channel): - """Creates a Future that tracks when a Channel is ready. + """Creates a Future that tracks when a Channel is ready. - Cancelling the Future does not affect the channel's state machine. - It merely decouples the Future from channel state machine. + Cancelling the Future does not affect the channel's state machine. + It merely decouples the Future from channel state machine. - Args: - channel: A Channel object. + Args: + channel: A Channel object. - Returns: - A Future object that matures when the channel connectivity is + Returns: + A Future object that matures when the channel connectivity is ChannelConnectivity.READY. - """ - from grpc import _utilities # pylint: disable=cyclic-import + """ + from grpc import _utilities # pylint: disable=cyclic-import return _utilities.channel_ready_future(channel) @@ -1907,17 +1907,17 @@ def insecure_channel(target, options=None, compression=None): The returned Channel is thread-safe. - Args: - target: The server address + Args: + target: The server address options: An optional list of key-value pairs (:term:`channel_arguments` - in gRPC Core runtime) to configure the channel. + in gRPC Core runtime) to configure the channel. compression: An optional value indicating the compression method to be used over the lifetime of the channel. This is an EXPERIMENTAL option. - Returns: + Returns: A Channel. - """ - from grpc import _channel # pylint: disable=cyclic-import + """ + from grpc import _channel # pylint: disable=cyclic-import return _channel.Channel(target, () if options is None else options, None, compression) @@ -1927,18 +1927,18 @@ def secure_channel(target, credentials, options=None, compression=None): The returned Channel is thread-safe. - Args: - target: The server address. - credentials: A ChannelCredentials instance. + Args: + target: The server address. + credentials: A ChannelCredentials instance. options: An optional list of key-value pairs (:term:`channel_arguments` - in gRPC Core runtime) to configure the channel. + in gRPC Core runtime) to configure the channel. compression: An optional value indicating the compression method to be used over the lifetime of the channel. This is an EXPERIMENTAL option. - Returns: + Returns: A Channel. - """ - from grpc import _channel # pylint: disable=cyclic-import + """ + from grpc import _channel # pylint: disable=cyclic-import from grpc.experimental import _insecure_channel_credentials if credentials._credentials is _insecure_channel_credentials: raise ValueError( @@ -1948,65 +1948,65 @@ def secure_channel(target, credentials, options=None, compression=None): credentials._credentials, compression) -def intercept_channel(channel, *interceptors): - """Intercepts a channel through a set of interceptors. - - This is an EXPERIMENTAL API. - - Args: - channel: A Channel. - interceptors: Zero or more objects of type - UnaryUnaryClientInterceptor, - UnaryStreamClientInterceptor, - StreamUnaryClientInterceptor, or - StreamStreamClientInterceptor. - Interceptors are given control in the order they are listed. - - Returns: - A Channel that intercepts each invocation via the provided interceptors. - - Raises: - TypeError: If interceptor does not derive from any of - UnaryUnaryClientInterceptor, - UnaryStreamClientInterceptor, - StreamUnaryClientInterceptor, or - StreamStreamClientInterceptor. - """ - from grpc import _interceptor # pylint: disable=cyclic-import - return _interceptor.intercept_channel(channel, *interceptors) - - -def server(thread_pool, - handlers=None, - interceptors=None, - options=None, +def intercept_channel(channel, *interceptors): + """Intercepts a channel through a set of interceptors. + + This is an EXPERIMENTAL API. + + Args: + channel: A Channel. + interceptors: Zero or more objects of type + UnaryUnaryClientInterceptor, + UnaryStreamClientInterceptor, + StreamUnaryClientInterceptor, or + StreamStreamClientInterceptor. + Interceptors are given control in the order they are listed. + + Returns: + A Channel that intercepts each invocation via the provided interceptors. + + Raises: + TypeError: If interceptor does not derive from any of + UnaryUnaryClientInterceptor, + UnaryStreamClientInterceptor, + StreamUnaryClientInterceptor, or + StreamStreamClientInterceptor. + """ + from grpc import _interceptor # pylint: disable=cyclic-import + return _interceptor.intercept_channel(channel, *interceptors) + + +def server(thread_pool, + handlers=None, + interceptors=None, + options=None, maximum_concurrent_rpcs=None, compression=None): """Creates a Server with which RPCs can be serviced. - Args: - thread_pool: A futures.ThreadPoolExecutor to be used by the Server - to execute RPC handlers. - handlers: An optional list of GenericRpcHandlers used for executing RPCs. - More handlers may be added by calling add_generic_rpc_handlers any time - before the server is started. - interceptors: An optional list of ServerInterceptor objects that observe - and optionally manipulate the incoming RPCs before handing them over to - handlers. The interceptors are given control in the order they are - specified. This is an EXPERIMENTAL API. + Args: + thread_pool: A futures.ThreadPoolExecutor to be used by the Server + to execute RPC handlers. + handlers: An optional list of GenericRpcHandlers used for executing RPCs. + More handlers may be added by calling add_generic_rpc_handlers any time + before the server is started. + interceptors: An optional list of ServerInterceptor objects that observe + and optionally manipulate the incoming RPCs before handing them over to + handlers. The interceptors are given control in the order they are + specified. This is an EXPERIMENTAL API. options: An optional list of key-value pairs (:term:`channel_arguments` in gRPC runtime) to configure the channel. - maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server - will service before returning RESOURCE_EXHAUSTED status, or None to - indicate no limit. + maximum_concurrent_rpcs: The maximum number of concurrent RPCs this server + will service before returning RESOURCE_EXHAUSTED status, or None to + indicate no limit. compression: An element of grpc.compression, e.g. grpc.compression.Gzip. This compression algorithm will be used for the lifetime of the server unless overridden. This is an EXPERIMENTAL option. - Returns: - A Server object. - """ - from grpc import _server # pylint: disable=cyclic-import + Returns: + A Server object. + """ + from grpc import _server # pylint: disable=cyclic-import return _server.create_server(thread_pool, () if handlers is None else handlers, () if interceptors is None else interceptors, @@ -2042,68 +2042,68 @@ from grpc._runtime_protos import protos, services, protos_and_services # pylint ################################### __all__ ################################# -__all__ = ( - 'FutureTimeoutError', - 'FutureCancelledError', - 'Future', - 'ChannelConnectivity', - 'StatusCode', +__all__ = ( + 'FutureTimeoutError', + 'FutureCancelledError', + 'Future', + 'ChannelConnectivity', + 'StatusCode', 'Status', - 'RpcError', - 'RpcContext', - 'Call', - 'ChannelCredentials', - 'CallCredentials', - 'AuthMetadataContext', - 'AuthMetadataPluginCallback', - 'AuthMetadataPlugin', + 'RpcError', + 'RpcContext', + 'Call', + 'ChannelCredentials', + 'CallCredentials', + 'AuthMetadataContext', + 'AuthMetadataPluginCallback', + 'AuthMetadataPlugin', 'Compression', - 'ClientCallDetails', - 'ServerCertificateConfiguration', - 'ServerCredentials', + 'ClientCallDetails', + 'ServerCertificateConfiguration', + 'ServerCredentials', 'LocalConnectionType', - 'UnaryUnaryMultiCallable', - 'UnaryStreamMultiCallable', - 'StreamUnaryMultiCallable', - 'StreamStreamMultiCallable', - 'UnaryUnaryClientInterceptor', - 'UnaryStreamClientInterceptor', - 'StreamUnaryClientInterceptor', - 'StreamStreamClientInterceptor', - 'Channel', - 'ServicerContext', - 'RpcMethodHandler', - 'HandlerCallDetails', - 'GenericRpcHandler', - 'ServiceRpcHandler', - 'Server', - 'ServerInterceptor', - 'unary_unary_rpc_method_handler', - 'unary_stream_rpc_method_handler', - 'stream_unary_rpc_method_handler', - 'stream_stream_rpc_method_handler', - 'method_handlers_generic_handler', - 'ssl_channel_credentials', - 'metadata_call_credentials', - 'access_token_call_credentials', - 'composite_call_credentials', - 'composite_channel_credentials', + 'UnaryUnaryMultiCallable', + 'UnaryStreamMultiCallable', + 'StreamUnaryMultiCallable', + 'StreamStreamMultiCallable', + 'UnaryUnaryClientInterceptor', + 'UnaryStreamClientInterceptor', + 'StreamUnaryClientInterceptor', + 'StreamStreamClientInterceptor', + 'Channel', + 'ServicerContext', + 'RpcMethodHandler', + 'HandlerCallDetails', + 'GenericRpcHandler', + 'ServiceRpcHandler', + 'Server', + 'ServerInterceptor', + 'unary_unary_rpc_method_handler', + 'unary_stream_rpc_method_handler', + 'stream_unary_rpc_method_handler', + 'stream_stream_rpc_method_handler', + 'method_handlers_generic_handler', + 'ssl_channel_credentials', + 'metadata_call_credentials', + 'access_token_call_credentials', + 'composite_call_credentials', + 'composite_channel_credentials', 'local_channel_credentials', 'local_server_credentials', 'alts_channel_credentials', 'alts_server_credentials', - 'ssl_server_credentials', - 'ssl_server_certificate_configuration', - 'dynamic_ssl_server_credentials', - 'channel_ready_future', - 'insecure_channel', - 'secure_channel', - 'intercept_channel', - 'server', + 'ssl_server_credentials', + 'ssl_server_certificate_configuration', + 'dynamic_ssl_server_credentials', + 'channel_ready_future', + 'insecure_channel', + 'secure_channel', + 'intercept_channel', + 'server', 'protos', 'services', 'protos_and_services', -) +) ############################### Extension Shims ################################ diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_auth.py b/contrib/libs/grpc/src/python/grpcio/grpc/_auth.py index 2d38320aff..e5f3296bed 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_auth.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_auth.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """GRPCAuthMetadataPlugins for standard authentication.""" import inspect @@ -31,7 +31,7 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin): # Hack to determine if these are JWT creds and we need to pass # additional_claims when getting a token self._is_jwt = 'additional_claims' in inspect.getargspec( # pylint: disable=deprecated-method - credentials.get_access_token).args + credentials.get_access_token).args def __call__(self, context, callback): try: @@ -48,7 +48,7 @@ class GoogleCallCredentials(grpc.AuthMetadataPlugin): _sign_request(callback, access_token, None) -class AccessTokenAuthMetadataPlugin(grpc.AuthMetadataPlugin): +class AccessTokenAuthMetadataPlugin(grpc.AuthMetadataPlugin): """Metadata wrapper for raw access token credentials.""" def __init__(self, access_token): diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_channel.py b/contrib/libs/grpc/src/python/grpcio/grpc/_channel.py index 11921d7883..e256d67e68 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_channel.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_channel.py @@ -1,21 +1,21 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Invocation-side implementation of gRPC Python.""" import copy import functools -import logging +import logging import os import sys import threading @@ -39,32 +39,32 @@ _EMPTY_FLAGS = 0 _DEFAULT_SINGLE_THREADED_UNARY_STREAM = os.getenv( "GRPC_SINGLE_THREADED_UNARY_STREAM") is not None -_UNARY_UNARY_INITIAL_DUE = ( - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.send_message, - cygrpc.OperationType.send_close_from_client, - cygrpc.OperationType.receive_initial_metadata, - cygrpc.OperationType.receive_message, - cygrpc.OperationType.receive_status_on_client, -) -_UNARY_STREAM_INITIAL_DUE = ( - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.send_message, - cygrpc.OperationType.send_close_from_client, - cygrpc.OperationType.receive_initial_metadata, - cygrpc.OperationType.receive_status_on_client, -) -_STREAM_UNARY_INITIAL_DUE = ( - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.receive_initial_metadata, - cygrpc.OperationType.receive_message, - cygrpc.OperationType.receive_status_on_client, -) -_STREAM_STREAM_INITIAL_DUE = ( - cygrpc.OperationType.send_initial_metadata, - cygrpc.OperationType.receive_initial_metadata, - cygrpc.OperationType.receive_status_on_client, -) +_UNARY_UNARY_INITIAL_DUE = ( + cygrpc.OperationType.send_initial_metadata, + cygrpc.OperationType.send_message, + cygrpc.OperationType.send_close_from_client, + cygrpc.OperationType.receive_initial_metadata, + cygrpc.OperationType.receive_message, + cygrpc.OperationType.receive_status_on_client, +) +_UNARY_STREAM_INITIAL_DUE = ( + cygrpc.OperationType.send_initial_metadata, + cygrpc.OperationType.send_message, + cygrpc.OperationType.send_close_from_client, + cygrpc.OperationType.receive_initial_metadata, + cygrpc.OperationType.receive_status_on_client, +) +_STREAM_UNARY_INITIAL_DUE = ( + cygrpc.OperationType.send_initial_metadata, + cygrpc.OperationType.receive_initial_metadata, + cygrpc.OperationType.receive_message, + cygrpc.OperationType.receive_status_on_client, +) +_STREAM_STREAM_INITIAL_DUE = ( + cygrpc.OperationType.send_initial_metadata, + cygrpc.OperationType.receive_initial_metadata, + cygrpc.OperationType.receive_status_on_client, +) _CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE = ( 'Exception calling channel subscription callback!') @@ -82,7 +82,7 @@ _NON_OK_RENDEZVOUS_REPR_FORMAT = ('<{} of RPC that terminated with:\n' def _deadline(timeout): - return None if timeout is None else time.time() + timeout + return None if timeout is None else time.time() + timeout def _unknown_code_details(unknown_cygrpc_code, details): @@ -120,19 +120,19 @@ def _abort(state, code, details): state.code = code state.details = details if state.initial_metadata is None: - state.initial_metadata = () - state.trailing_metadata = () + state.initial_metadata = () + state.trailing_metadata = () def _handle_event(event, state, response_deserializer): callbacks = [] for batch_operation in event.batch_operations: - operation_type = batch_operation.type() + operation_type = batch_operation.type() state.due.remove(operation_type) if operation_type == cygrpc.OperationType.receive_initial_metadata: - state.initial_metadata = batch_operation.initial_metadata() + state.initial_metadata = batch_operation.initial_metadata() elif operation_type == cygrpc.OperationType.receive_message: - serialized_response = batch_operation.message() + serialized_response = batch_operation.message() if serialized_response is not None: response = _common.deserialize(serialized_response, response_deserializer) @@ -142,24 +142,24 @@ def _handle_event(event, state, response_deserializer): else: state.response = response elif operation_type == cygrpc.OperationType.receive_status_on_client: - state.trailing_metadata = batch_operation.trailing_metadata() + state.trailing_metadata = batch_operation.trailing_metadata() if state.code is None: code = _common.CYGRPC_STATUS_CODE_TO_STATUS_CODE.get( - batch_operation.code()) + batch_operation.code()) if code is None: state.code = grpc.StatusCode.UNKNOWN state.details = _unknown_code_details( - code, batch_operation.details()) + code, batch_operation.details()) else: state.code = code - state.details = batch_operation.details() + state.details = batch_operation.details() state.debug_error_string = batch_operation.error_string() callbacks.extend(state.callbacks) state.callbacks = None return callbacks -def _event_handler(state, response_deserializer): +def _event_handler(state, response_deserializer): def handle_event(event): with state.condition: @@ -180,11 +180,11 @@ def _event_handler(state, response_deserializer): #pylint: disable=too-many-statements -def _consume_request_iterator(request_iterator, state, call, request_serializer, - event_handler): +def _consume_request_iterator(request_iterator, state, call, request_serializer, + event_handler): """Consume a request iterator supplied by the user.""" - def consume_request_iterator(): # pylint: disable=too-many-branches + def consume_request_iterator(): # pylint: disable=too-many-branches # Iterate over the request iterator until it is exhausted or an error # condition is encountered. while True: @@ -195,15 +195,15 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, request = next(request_iterator) except StopIteration: break - except Exception: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except cygrpc.return_from_user_request_generator() return_from_user_request_generator_invoked = True - code = grpc.StatusCode.UNKNOWN - details = 'Exception iterating requests!' + code = grpc.StatusCode.UNKNOWN + details = 'Exception iterating requests!' _LOGGER.exception(details) - call.cancel(_common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], - details) - _abort(state, code, details) + call.cancel(_common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], + details) + _abort(state, code, details) return finally: if not return_from_user_request_generator_invoked: @@ -214,19 +214,19 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, if serialized_request is None: code = grpc.StatusCode.INTERNAL details = 'Exception serializing request!' - call.cancel( - _common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], - details) - _abort(state, code, details) + call.cancel( + _common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], + details) + _abort(state, code, details) return else: - operations = (cygrpc.SendMessageOperation( + operations = (cygrpc.SendMessageOperation( serialized_request, _EMPTY_FLAGS),) - operating = call.operate(operations, event_handler) - if operating: - state.due.add(cygrpc.OperationType.send_message) - else: - return + operating = call.operate(operations, event_handler) + if operating: + state.due.add(cygrpc.OperationType.send_message) + else: + return def _done(): return (state.code is not None or @@ -245,10 +245,10 @@ def _consume_request_iterator(request_iterator, state, call, request_serializer, with state.condition: if state.code is None: operations = ( - cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),) - operating = call.operate(operations, event_handler) - if operating: - state.due.add(cygrpc.OperationType.send_close_from_client) + cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS),) + operating = call.operate(operations, event_handler) + if operating: + state.due.add(cygrpc.OperationType.send_close_from_client) consumption_thread = cygrpc.ForkManagedThread( target=consume_request_iterator) @@ -386,12 +386,12 @@ class _Rendezvous(grpc.RpcError, grpc.RpcContext): """See grpc.RpcContext.cancel""" with self._state.condition: if self._state.code is None: - code = grpc.StatusCode.CANCELLED - details = 'Locally cancelled by application!' - self._call.cancel( - _common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], details) + code = grpc.StatusCode.CANCELLED + details = 'Locally cancelled by application!' + self._call.cancel( + _common.STATUS_CODE_TO_CYGRPC_STATUS_CODE[code], details) self._state.cancelled = True - _abort(self._state, code, details) + _abort(self._state, code, details) self._state.condition.notify_all() return True else: @@ -773,13 +773,13 @@ class _MultiThreadedRendezvous(_Rendezvous, grpc.Call, grpc.Future): # pylint: def _next(self): with self._state.condition: if self._state.code is None: - event_handler = _event_handler(self._state, + event_handler = _event_handler(self._state, self._response_deserializer) - operating = self._call.operate( - (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), + operating = self._call.operate( + (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), event_handler) - if operating: - self._state.due.add(cygrpc.OperationType.receive_message) + if operating: + self._state.due.add(cygrpc.OperationType.receive_message) elif self._state.code is grpc.StatusCode.OK: raise StopIteration() else: @@ -804,18 +804,18 @@ class _MultiThreadedRendezvous(_Rendezvous, grpc.Call, grpc.Future): # pylint: def _start_unary_request(request, timeout, request_serializer): - deadline = _deadline(timeout) + deadline = _deadline(timeout) serialized_request = _common.serialize(request, request_serializer) if serialized_request is None: - state = _RPCState((), (), (), grpc.StatusCode.INTERNAL, + state = _RPCState((), (), (), grpc.StatusCode.INTERNAL, 'Exception serializing request!') error = _InactiveRpcError(state) return deadline, None, error else: - return deadline, serialized_request, None + return deadline, serialized_request, None -def _end_unary_response_blocking(state, call, with_call, deadline): +def _end_unary_response_blocking(state, call, with_call, deadline): if state.code is grpc.StatusCode.OK: if with_call: rendezvous = _MultiThreadedRendezvous(state, call, None, deadline) @@ -827,26 +827,26 @@ def _end_unary_response_blocking(state, call, with_call, deadline): def _stream_unary_invocation_operationses(metadata, initial_metadata_flags): - return ( - ( + return ( + ( cygrpc.SendInitialMetadataOperation(metadata, initial_metadata_flags), - cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS), - cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), - ), - (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), - ) - - + cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS), + cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), + ), + (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), + ) + + def _stream_unary_invocation_operationses_and_tags(metadata, initial_metadata_flags): - return tuple(( - operations, - None, + return tuple(( + operations, + None, ) for operations in _stream_unary_invocation_operationses( metadata, initial_metadata_flags)) - - + + def _determine_deadline(user_deadline): parent_deadline = cygrpc.get_deadline_from_context() if parent_deadline is None and user_deadline is None: @@ -872,43 +872,43 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): self._context = cygrpc.build_census_context() def _prepare(self, request, timeout, metadata, wait_for_ready, compression): - deadline, serialized_request, rendezvous = _start_unary_request( - request, timeout, self._request_serializer) + deadline, serialized_request, rendezvous = _start_unary_request( + request, timeout, self._request_serializer) initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready( wait_for_ready) augmented_metadata = _compression.augment_metadata( metadata, compression) if serialized_request is None: - return None, None, None, rendezvous + return None, None, None, rendezvous else: state = _RPCState(_UNARY_UNARY_INITIAL_DUE, None, None, None, None) operations = ( cygrpc.SendInitialMetadataOperation(augmented_metadata, initial_metadata_flags), - cygrpc.SendMessageOperation(serialized_request, _EMPTY_FLAGS), - cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS), - cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS), - cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS), - cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), - ) - return state, operations, deadline, None + cygrpc.SendMessageOperation(serialized_request, _EMPTY_FLAGS), + cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS), + cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS), + cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS), + cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), + ) + return state, operations, deadline, None def _blocking(self, request, timeout, metadata, credentials, wait_for_ready, compression): - state, operations, deadline, rendezvous = self._prepare( + state, operations, deadline, rendezvous = self._prepare( request, timeout, metadata, wait_for_ready, compression) - if state is None: + if state is None: raise rendezvous # pylint: disable-msg=raising-bad-type else: - call = self._channel.segregated_call( + call = self._channel.segregated_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, _determine_deadline(deadline), metadata, None if credentials is None else credentials._credentials, (( - operations, - None, + operations, + None, ),), self._context) - event = call.next_event() - _handle_event(event, state, self._response_deserializer) + event = call.next_event() + _handle_event(event, state, self._response_deserializer) return state, call def __call__(self, @@ -920,7 +920,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): compression=None): state, call, = self._blocking(request, timeout, metadata, credentials, wait_for_ready, compression) - return _end_unary_response_blocking(state, call, False, None) + return _end_unary_response_blocking(state, call, False, None) def with_call(self, request, @@ -931,7 +931,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): compression=None): state, call, = self._blocking(request, timeout, metadata, credentials, wait_for_ready, compression) - return _end_unary_response_blocking(state, call, True, None) + return _end_unary_response_blocking(state, call, True, None) def future(self, request, @@ -940,13 +940,13 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): credentials=None, wait_for_ready=None, compression=None): - state, operations, deadline, rendezvous = self._prepare( + state, operations, deadline, rendezvous = self._prepare( request, timeout, metadata, wait_for_ready, compression) - if state is None: + if state is None: raise rendezvous # pylint: disable-msg=raising-bad-type else: - event_handler = _event_handler(state, self._response_deserializer) - call = self._managed_call( + event_handler = _event_handler(state, self._response_deserializer) + call = self._managed_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, deadline, metadata, None if credentials is None else credentials._credentials, @@ -1026,8 +1026,8 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): credentials=None, wait_for_ready=None, compression=None): - deadline, serialized_request, rendezvous = _start_unary_request( - request, timeout, self._request_serializer) + deadline, serialized_request, rendezvous = _start_unary_request( + request, timeout, self._request_serializer) initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready( wait_for_ready) if serialized_request is None: @@ -1036,18 +1036,18 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): augmented_metadata = _compression.augment_metadata( metadata, compression) state = _RPCState(_UNARY_STREAM_INITIAL_DUE, None, None, None, None) - operationses = ( - ( + operationses = ( + ( cygrpc.SendInitialMetadataOperation(augmented_metadata, initial_metadata_flags), - cygrpc.SendMessageOperation(serialized_request, - _EMPTY_FLAGS), - cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS), - cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), - ), - (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), - ) - call = self._managed_call( + cygrpc.SendMessageOperation(serialized_request, + _EMPTY_FLAGS), + cygrpc.SendCloseFromClientOperation(_EMPTY_FLAGS), + cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), + ), + (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), + ) + call = self._managed_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, _determine_deadline(deadline), metadata, None if credentials is None else credentials._credentials, @@ -1073,22 +1073,22 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): def _blocking(self, request_iterator, timeout, metadata, credentials, wait_for_ready, compression): - deadline = _deadline(timeout) + deadline = _deadline(timeout) state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready( wait_for_ready) augmented_metadata = _compression.augment_metadata( metadata, compression) - call = self._channel.segregated_call( + call = self._channel.segregated_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, _determine_deadline(deadline), augmented_metadata, None if credentials is None else credentials._credentials, _stream_unary_invocation_operationses_and_tags( augmented_metadata, initial_metadata_flags), self._context) - _consume_request_iterator(request_iterator, state, call, - self._request_serializer, None) + _consume_request_iterator(request_iterator, state, call, + self._request_serializer, None) while True: - event = call.next_event() + event = call.next_event() with state.condition: _handle_event(event, state, self._response_deserializer) state.condition.notify_all() @@ -1103,9 +1103,9 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): credentials=None, wait_for_ready=None, compression=None): - state, call, = self._blocking(request_iterator, timeout, metadata, + state, call, = self._blocking(request_iterator, timeout, metadata, credentials, wait_for_ready, compression) - return _end_unary_response_blocking(state, call, False, None) + return _end_unary_response_blocking(state, call, False, None) def with_call(self, request_iterator, @@ -1114,9 +1114,9 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): credentials=None, wait_for_ready=None, compression=None): - state, call, = self._blocking(request_iterator, timeout, metadata, + state, call, = self._blocking(request_iterator, timeout, metadata, credentials, wait_for_ready, compression) - return _end_unary_response_blocking(state, call, True, None) + return _end_unary_response_blocking(state, call, True, None) def future(self, request_iterator, @@ -1125,22 +1125,22 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): credentials=None, wait_for_ready=None, compression=None): - deadline = _deadline(timeout) + deadline = _deadline(timeout) state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) - event_handler = _event_handler(state, self._response_deserializer) + event_handler = _event_handler(state, self._response_deserializer) initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready( wait_for_ready) augmented_metadata = _compression.augment_metadata( metadata, compression) - call = self._managed_call( + call = self._managed_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, deadline, augmented_metadata, None if credentials is None else credentials._credentials, _stream_unary_invocation_operationses(metadata, initial_metadata_flags), event_handler, self._context) - _consume_request_iterator(request_iterator, state, call, - self._request_serializer, event_handler) + _consume_request_iterator(request_iterator, state, call, + self._request_serializer, event_handler) return _MultiThreadedRendezvous(state, call, self._response_deserializer, deadline) @@ -1164,28 +1164,28 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): credentials=None, wait_for_ready=None, compression=None): - deadline = _deadline(timeout) + deadline = _deadline(timeout) state = _RPCState(_STREAM_STREAM_INITIAL_DUE, None, None, None, None) initial_metadata_flags = _InitialMetadataFlags().with_wait_for_ready( wait_for_ready) augmented_metadata = _compression.augment_metadata( metadata, compression) - operationses = ( - ( + operationses = ( + ( cygrpc.SendInitialMetadataOperation(augmented_metadata, initial_metadata_flags), - cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), - ), - (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), - ) - event_handler = _event_handler(state, self._response_deserializer) - call = self._managed_call( + cygrpc.ReceiveStatusOnClientOperation(_EMPTY_FLAGS), + ), + (cygrpc.ReceiveInitialMetadataOperation(_EMPTY_FLAGS),), + ) + event_handler = _event_handler(state, self._response_deserializer) + call = self._managed_call( cygrpc.PropagationConstants.GRPC_PROPAGATE_DEFAULTS, self._method, None, _determine_deadline(deadline), augmented_metadata, None if credentials is None else credentials._credentials, operationses, event_handler, self._context) - _consume_request_iterator(request_iterator, state, call, - self._request_serializer, event_handler) + _consume_request_iterator(request_iterator, state, call, + self._request_serializer, event_handler) return _MultiThreadedRendezvous(state, call, self._response_deserializer, deadline) @@ -1213,7 +1213,7 @@ class _ChannelCallState(object): def __init__(self, channel): self.lock = threading.Lock() self.channel = channel - self.managed_calls = 0 + self.managed_calls = 0 self.threading = False def reset_postfork_child(self): @@ -1232,14 +1232,14 @@ def _run_channel_spin_thread(state): def channel_spin(): while True: cygrpc.block_if_fork_in_progress(state) - event = state.channel.next_call_event() + event = state.channel.next_call_event() if event.completion_type == cygrpc.CompletionType.queue_timeout: continue - call_completed = event.tag(event) - if call_completed: + call_completed = event.tag(event) + if call_completed: with state.lock: - state.managed_calls -= 1 - if state.managed_calls == 0: + state.managed_calls -= 1 + if state.managed_calls == 0: return channel_spin_thread = cygrpc.ForkManagedThread(target=channel_spin) @@ -1249,41 +1249,41 @@ def _run_channel_spin_thread(state): def _channel_managed_call_management(state): - # pylint: disable=too-many-arguments - def create(flags, method, host, deadline, metadata, credentials, + # pylint: disable=too-many-arguments + def create(flags, method, host, deadline, metadata, credentials, operationses, event_handler, context): - """Creates a cygrpc.IntegratedCall. - - Args: - flags: An integer bitfield of call flags. - method: The RPC method. - host: A host string for the created call. - deadline: A float to be the deadline of the created call or None if - the call is to have an infinite deadline. - metadata: The metadata for the call or None. - credentials: A cygrpc.CallCredentials or None. - operationses: An iterable of iterables of cygrpc.Operations to be - started on the call. - event_handler: A behavior to call to handle the events resultant from - the operations on the call. + """Creates a cygrpc.IntegratedCall. + + Args: + flags: An integer bitfield of call flags. + method: The RPC method. + host: A host string for the created call. + deadline: A float to be the deadline of the created call or None if + the call is to have an infinite deadline. + metadata: The metadata for the call or None. + credentials: A cygrpc.CallCredentials or None. + operationses: An iterable of iterables of cygrpc.Operations to be + started on the call. + event_handler: A behavior to call to handle the events resultant from + the operations on the call. context: Context object for distributed tracing. - Returns: - A cygrpc.IntegratedCall with which to conduct an RPC. - """ - operationses_and_tags = tuple(( - operations, - event_handler, - ) for operations in operationses) - with state.lock: - call = state.channel.integrated_call(flags, method, host, deadline, - metadata, credentials, + Returns: + A cygrpc.IntegratedCall with which to conduct an RPC. + """ + operationses_and_tags = tuple(( + operations, + event_handler, + ) for operations in operationses) + with state.lock: + call = state.channel.integrated_call(flags, method, host, deadline, + metadata, credentials, operationses_and_tags, context) - if state.managed_calls == 0: - state.managed_calls = 1 - _run_channel_spin_thread(state) - else: - state.managed_calls += 1 - return call + if state.managed_calls == 0: + state.managed_calls = 1 + _run_channel_spin_thread(state) + else: + state.managed_calls += 1 + return call return create @@ -1365,8 +1365,8 @@ def _poll_connectivity(state, channel, initial_try_to_connect): if callbacks: _spawn_delivery(state, callbacks) while True: - event = channel.watch_connectivity_state(connectivity, - time.time() + 0.2) + event = channel.watch_connectivity_state(connectivity, + time.time() + 0.2) cygrpc.block_if_fork_in_progress(state) with state.lock: if not state.callbacks_and_connectivities and not state.try_to_connect: @@ -1409,8 +1409,8 @@ def _subscribe(state, callback, try_to_connect): def _unsubscribe(state, callback): with state.lock: - for index, (subscribed_callback, unused_connectivity) in enumerate( - state.callbacks_and_connectivities): + for index, (subscribed_callback, unused_connectivity) in enumerate( + state.callbacks_and_connectivities): if callback == subscribed_callback: state.callbacks_and_connectivities.pop(index) break @@ -1442,13 +1442,13 @@ class Channel(grpc.Channel): def __init__(self, target, options, credentials, compression): """Constructor. - Args: - target: The target to which to connect. - options: Configuration options for the channel. - credentials: A cygrpc.ChannelCredentials or None. + Args: + target: The target to which to connect. + options: Configuration options for the channel. + credentials: A cygrpc.ChannelCredentials or None. compression: An optional value indicating the compression method to be used over the lifetime of the channel. - """ + """ python_options, core_options = _separate_channel_options(options) self._single_threaded_unary_stream = _DEFAULT_SINGLE_THREADED_UNARY_STREAM self._process_python_options(python_options) @@ -1476,7 +1476,7 @@ class Channel(grpc.Channel): request_serializer=None, response_deserializer=None): return _UnaryUnaryMultiCallable( - self._channel, _channel_managed_call_management(self._call_state), + self._channel, _channel_managed_call_management(self._call_state), _common.encode(method), request_serializer, response_deserializer) def unary_stream(self, @@ -1503,7 +1503,7 @@ class Channel(grpc.Channel): request_serializer=None, response_deserializer=None): return _StreamUnaryMultiCallable( - self._channel, _channel_managed_call_management(self._call_state), + self._channel, _channel_managed_call_management(self._call_state), _common.encode(method), request_serializer, response_deserializer) def stream_stream(self, @@ -1511,7 +1511,7 @@ class Channel(grpc.Channel): request_serializer=None, response_deserializer=None): return _StreamStreamMultiCallable( - self._channel, _channel_managed_call_management(self._call_state), + self._channel, _channel_managed_call_management(self._call_state), _common.encode(method), request_serializer, response_deserializer) def _unsubscribe_all(self): @@ -1520,36 +1520,36 @@ class Channel(grpc.Channel): with state.lock: del state.callbacks_and_connectivities[:] - def _close(self): + def _close(self): self._unsubscribe_all() - self._channel.close(cygrpc.StatusCode.cancelled, 'Channel closed!') + self._channel.close(cygrpc.StatusCode.cancelled, 'Channel closed!') cygrpc.fork_unregister_channel(self) - + def _close_on_fork(self): self._unsubscribe_all() self._channel.close_on_fork(cygrpc.StatusCode.cancelled, 'Channel closed due to fork') - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - self._close() - return False - - def close(self): - self._close() - + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self._close() + return False + + def close(self): + self._close() + def __del__(self): - # TODO(https://github.com/grpc/grpc/issues/12531): Several releases - # after 1.12 (1.16 or thereabouts?) add a "self._channel.close" call - # here (or more likely, call self._close() here). We don't do this today - # because many valid use cases today allow the channel to be deleted - # immediately after stubs are created. After a sufficient period of time - # has passed for all users to be trusted to hang out to their channels - # for as long as they are in use and to close them after using them, - # then deletion of this grpc._channel.Channel instance can be made to - # effect closure of the underlying cygrpc.Channel instance. + # TODO(https://github.com/grpc/grpc/issues/12531): Several releases + # after 1.12 (1.16 or thereabouts?) add a "self._channel.close" call + # here (or more likely, call self._close() here). We don't do this today + # because many valid use cases today allow the channel to be deleted + # immediately after stubs are created. After a sufficient period of time + # has passed for all users to be trusted to hang out to their channels + # for as long as they are in use and to close them after using them, + # then deletion of this grpc._channel.Channel instance can be made to + # effect closure of the underlying cygrpc.Channel instance. try: self._unsubscribe_all() except: # pylint: disable=bare-except diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_common.py b/contrib/libs/grpc/src/python/grpcio/grpc/_common.py index 128124c325..d86dcbd9bb 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_common.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_common.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Shared implementation.""" import logging diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi index 251efe15b3..1b09b8b984 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi @@ -1,36 +1,36 @@ # Copyright 2018 The gRPC Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + cdef tuple _wrap_grpc_arg(grpc_arg arg) - + cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg) cdef class _ChannelArg: - cdef grpc_arg c_argument - + cdef grpc_arg c_argument + cdef void c(self, argument, references) except * - - + + cdef class _ChannelArgs: - - cdef readonly tuple _arguments + + cdef readonly tuple _arguments cdef list _channel_args - cdef readonly list _references - cdef grpc_channel_args _c_arguments - + cdef readonly list _references + cdef grpc_channel_args _c_arguments + cdef grpc_channel_args *c_args(self) except * diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi index 9df308cdbc..161b387df9 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi @@ -1,20 +1,20 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + cdef class _GrpcArgWrapper: - + cdef grpc_arg arg @@ -32,54 +32,54 @@ cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg): cdef class _ChannelArg: cdef void c(self, argument, references) except *: - key, value = argument - cdef bytes encoded_key = _encode(key) - if encoded_key is not key: - references.append(encoded_key) - self.c_argument.key = encoded_key - if isinstance(value, int): - self.c_argument.type = GRPC_ARG_INTEGER - self.c_argument.value.integer = value - elif isinstance(value, (bytes, str, unicode,)): - self.c_argument.type = GRPC_ARG_STRING - encoded_value = _encode(value) - if encoded_value is not value: - references.append(encoded_value) - self.c_argument.value.string = encoded_value + key, value = argument + cdef bytes encoded_key = _encode(key) + if encoded_key is not key: + references.append(encoded_key) + self.c_argument.key = encoded_key + if isinstance(value, int): + self.c_argument.type = GRPC_ARG_INTEGER + self.c_argument.value.integer = value + elif isinstance(value, (bytes, str, unicode,)): + self.c_argument.type = GRPC_ARG_STRING + encoded_value = _encode(value) + if encoded_value is not value: + references.append(encoded_value) + self.c_argument.value.string = encoded_value elif isinstance(value, _GrpcArgWrapper): self.c_argument = (<_GrpcArgWrapper>value).arg - elif hasattr(value, '__int__'): - # Pointer objects must override __int__() to return - # the underlying C address (Python ints are word size). The - # lifecycle of the pointer is fixed to the lifecycle of the - # python object wrapping it. - self.c_argument.type = GRPC_ARG_POINTER + elif hasattr(value, '__int__'): + # Pointer objects must override __int__() to return + # the underlying C address (Python ints are word size). The + # lifecycle of the pointer is fixed to the lifecycle of the + # python object wrapping it. + self.c_argument.type = GRPC_ARG_POINTER self.c_argument.value.pointer.vtable = &default_vtable - self.c_argument.value.pointer.address = <void*>(<intptr_t>int(value)) - else: - raise TypeError( - 'Expected int, bytes, or behavior, got {}'.format(type(value))) - - + self.c_argument.value.pointer.address = <void*>(<intptr_t>int(value)) + else: + raise TypeError( + 'Expected int, bytes, or behavior, got {}'.format(type(value))) + + cdef class _ChannelArgs: - - def __cinit__(self, arguments): - self._arguments = () if arguments is None else tuple(arguments) + + def __cinit__(self, arguments): + self._arguments = () if arguments is None else tuple(arguments) self._channel_args = [] - self._references = [] - self._c_arguments.arguments_length = len(self._arguments) + self._references = [] + self._c_arguments.arguments_length = len(self._arguments) if self._c_arguments.arguments_length != 0: - self._c_arguments.arguments = <grpc_arg *>gpr_malloc( - self._c_arguments.arguments_length * sizeof(grpc_arg)) - for index, argument in enumerate(self._arguments): + self._c_arguments.arguments = <grpc_arg *>gpr_malloc( + self._c_arguments.arguments_length * sizeof(grpc_arg)) + for index, argument in enumerate(self._arguments): channel_arg = _ChannelArg() channel_arg.c(argument, self._references) self._c_arguments.arguments[index] = channel_arg.c_argument self._channel_args.append(channel_arg) - + cdef grpc_channel_args *c_args(self) except *: return &self._c_arguments def __dealloc__(self): if self._c_arguments.arguments != NULL: - gpr_free(self._c_arguments.arguments) + gpr_free(self._c_arguments.arguments) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi index 8babeb4536..54760788b0 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pxd.pxi @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef class Call: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi index bdd155bea9..6cebd1ac51 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/call.pyx.pxi @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef class Call: @@ -24,16 +24,16 @@ cdef class Call: def _start_batch(self, operations, tag, retain_self): if not self.is_valid: raise ValueError("invalid call object cannot be used from Python") - cdef _BatchOperationTag batch_operation_tag = _BatchOperationTag( - tag, operations, self if retain_self else None) - batch_operation_tag.prepare() - cpython.Py_INCREF(batch_operation_tag) - cdef grpc_call_error error + cdef _BatchOperationTag batch_operation_tag = _BatchOperationTag( + tag, operations, self if retain_self else None) + batch_operation_tag.prepare() + cpython.Py_INCREF(batch_operation_tag) + cdef grpc_call_error error with nogil: - error = grpc_call_start_batch( - self.c_call, batch_operation_tag.c_ops, batch_operation_tag.c_nops, - <cpython.PyObject *>batch_operation_tag, NULL) - return error + error = grpc_call_start_batch( + self.c_call, batch_operation_tag.c_ops, batch_operation_tag.c_nops, + <cpython.PyObject *>batch_operation_tag, NULL) + return error def start_client_batch(self, operations, tag): # We don't reference this call in the operations tag because @@ -66,12 +66,12 @@ cdef class Call: result = grpc_call_cancel(self.c_call, NULL) return result - def set_credentials(self, CallCredentials call_credentials not None): - cdef grpc_call_credentials *c_call_credentials = call_credentials.c() - cdef grpc_call_error call_error = grpc_call_set_credentials( - self.c_call, c_call_credentials) - grpc_call_credentials_release(c_call_credentials) - return call_error + def set_credentials(self, CallCredentials call_credentials not None): + cdef grpc_call_credentials *c_call_credentials = call_credentials.c() + cdef grpc_call_error call_error = grpc_call_set_credentials( + self.c_call, c_call_credentials) + grpc_call_credentials_release(c_call_credentials) + return call_error def peer(self): cdef char *peer = NULL diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi index eb27f2df7a..16caaf51cb 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi @@ -1,74 +1,74 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef _check_call_error_no_metadata(c_call_error) - - -cdef _check_and_raise_call_error_no_metadata(c_call_error) - - -cdef _check_call_error(c_call_error, metadata) - - -cdef class _CallState: - - cdef grpc_call *c_call - cdef set due - - -cdef class _ChannelState: - - cdef object condition - cdef grpc_channel *c_channel - # A boolean field indicating that the channel is open (if True) or is being - # closed (i.e. a call to close is currently executing) or is closed (if - # False). - # TODO(https://github.com/grpc/grpc/issues/3064): Eliminate "is being closed" - # a state in which condition may be acquired by any thread, eliminate this - # field and just use the NULLness of c_channel as an indication that the - # channel is closed. - cdef object open +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef _check_call_error_no_metadata(c_call_error) + + +cdef _check_and_raise_call_error_no_metadata(c_call_error) + + +cdef _check_call_error(c_call_error, metadata) + + +cdef class _CallState: + + cdef grpc_call *c_call + cdef set due + + +cdef class _ChannelState: + + cdef object condition + cdef grpc_channel *c_channel + # A boolean field indicating that the channel is open (if True) or is being + # closed (i.e. a call to close is currently executing) or is closed (if + # False). + # TODO(https://github.com/grpc/grpc/issues/3064): Eliminate "is being closed" + # a state in which condition may be acquired by any thread, eliminate this + # field and just use the NULLness of c_channel as an indication that the + # channel is closed. + cdef object open cdef object closed_reason - - # A dict from _BatchOperationTag to _CallState - cdef dict integrated_call_states - cdef grpc_completion_queue *c_call_completion_queue - - # A set of _CallState - cdef set segregated_call_states - - cdef set connectivity_due - cdef grpc_completion_queue *c_connectivity_completion_queue - - -cdef class IntegratedCall: - - cdef _ChannelState _channel_state - cdef _CallState _call_state - - -cdef class SegregatedCall: - - cdef _ChannelState _channel_state - cdef _CallState _call_state - cdef grpc_completion_queue *_c_completion_queue - - + + # A dict from _BatchOperationTag to _CallState + cdef dict integrated_call_states + cdef grpc_completion_queue *c_call_completion_queue + + # A set of _CallState + cdef set segregated_call_states + + cdef set connectivity_due + cdef grpc_completion_queue *c_connectivity_completion_queue + + +cdef class IntegratedCall: + + cdef _ChannelState _channel_state + cdef _CallState _call_state + + +cdef class SegregatedCall: + + cdef _ChannelState _channel_state + cdef _CallState _call_state + cdef grpc_completion_queue *_c_completion_queue + + cdef class Channel: - cdef _ChannelState _state + cdef _ChannelState _state # TODO(https://github.com/grpc/grpc/issues/15662): Eliminate this. cdef tuple _arguments diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index 74c7f6c140..1f2983699c 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -1,155 +1,155 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -_INTERNAL_CALL_ERROR_MESSAGE_FORMAT = ( - 'Internal gRPC call error %d. ' + - 'Please report to https://github.com/grpc/grpc/issues') - - -cdef str _call_error_metadata(metadata): - return 'metadata was invalid: %s' % metadata - - -cdef str _call_error_no_metadata(c_call_error): - return _INTERNAL_CALL_ERROR_MESSAGE_FORMAT % c_call_error - - -cdef str _call_error(c_call_error, metadata): - if c_call_error == GRPC_CALL_ERROR_INVALID_METADATA: - return _call_error_metadata(metadata) - else: - return _call_error_no_metadata(c_call_error) - - -cdef _check_call_error_no_metadata(c_call_error): - if c_call_error != GRPC_CALL_OK: - return _INTERNAL_CALL_ERROR_MESSAGE_FORMAT % c_call_error - else: - return None - - -cdef _check_and_raise_call_error_no_metadata(c_call_error): - error = _check_call_error_no_metadata(c_call_error) - if error is not None: - raise ValueError(error) - - -cdef _check_call_error(c_call_error, metadata): - if c_call_error == GRPC_CALL_ERROR_INVALID_METADATA: - return _call_error_metadata(metadata) - else: - return _check_call_error_no_metadata(c_call_error) - - -cdef void _raise_call_error_no_metadata(c_call_error) except *: - raise ValueError(_call_error_no_metadata(c_call_error)) - - -cdef void _raise_call_error(c_call_error, metadata) except *: - raise ValueError(_call_error(c_call_error, metadata)) - - -cdef _destroy_c_completion_queue(grpc_completion_queue *c_completion_queue): - grpc_completion_queue_shutdown(c_completion_queue) - grpc_completion_queue_destroy(c_completion_queue) - - -cdef class _CallState: - - def __cinit__(self): - self.due = set() - - -cdef class _ChannelState: - - def __cinit__(self): - self.condition = threading.Condition() - self.open = True - self.integrated_call_states = {} - self.segregated_call_states = set() - self.connectivity_due = set() +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +_INTERNAL_CALL_ERROR_MESSAGE_FORMAT = ( + 'Internal gRPC call error %d. ' + + 'Please report to https://github.com/grpc/grpc/issues') + + +cdef str _call_error_metadata(metadata): + return 'metadata was invalid: %s' % metadata + + +cdef str _call_error_no_metadata(c_call_error): + return _INTERNAL_CALL_ERROR_MESSAGE_FORMAT % c_call_error + + +cdef str _call_error(c_call_error, metadata): + if c_call_error == GRPC_CALL_ERROR_INVALID_METADATA: + return _call_error_metadata(metadata) + else: + return _call_error_no_metadata(c_call_error) + + +cdef _check_call_error_no_metadata(c_call_error): + if c_call_error != GRPC_CALL_OK: + return _INTERNAL_CALL_ERROR_MESSAGE_FORMAT % c_call_error + else: + return None + + +cdef _check_and_raise_call_error_no_metadata(c_call_error): + error = _check_call_error_no_metadata(c_call_error) + if error is not None: + raise ValueError(error) + + +cdef _check_call_error(c_call_error, metadata): + if c_call_error == GRPC_CALL_ERROR_INVALID_METADATA: + return _call_error_metadata(metadata) + else: + return _check_call_error_no_metadata(c_call_error) + + +cdef void _raise_call_error_no_metadata(c_call_error) except *: + raise ValueError(_call_error_no_metadata(c_call_error)) + + +cdef void _raise_call_error(c_call_error, metadata) except *: + raise ValueError(_call_error(c_call_error, metadata)) + + +cdef _destroy_c_completion_queue(grpc_completion_queue *c_completion_queue): + grpc_completion_queue_shutdown(c_completion_queue) + grpc_completion_queue_destroy(c_completion_queue) + + +cdef class _CallState: + + def __cinit__(self): + self.due = set() + + +cdef class _ChannelState: + + def __cinit__(self): + self.condition = threading.Condition() + self.open = True + self.integrated_call_states = {} + self.segregated_call_states = set() + self.connectivity_due = set() self.closed_reason = None - - -cdef tuple _operate(grpc_call *c_call, object operations, object user_tag): - cdef grpc_call_error c_call_error - cdef _BatchOperationTag tag = _BatchOperationTag(user_tag, operations, None) - tag.prepare() - cpython.Py_INCREF(tag) - with nogil: - c_call_error = grpc_call_start_batch( - c_call, tag.c_ops, tag.c_nops, <cpython.PyObject *>tag, NULL) - return c_call_error, tag - - -cdef object _operate_from_integrated_call( - _ChannelState channel_state, _CallState call_state, object operations, - object user_tag): - cdef grpc_call_error c_call_error - cdef _BatchOperationTag tag - with channel_state.condition: - if call_state.due: - c_call_error, tag = _operate(call_state.c_call, operations, user_tag) - if c_call_error == GRPC_CALL_OK: - call_state.due.add(tag) - channel_state.integrated_call_states[tag] = call_state - return True - else: - _raise_call_error_no_metadata(c_call_error) - else: - return False - - -cdef object _operate_from_segregated_call( - _ChannelState channel_state, _CallState call_state, object operations, - object user_tag): - cdef grpc_call_error c_call_error - cdef _BatchOperationTag tag - with channel_state.condition: - if call_state.due: - c_call_error, tag = _operate(call_state.c_call, operations, user_tag) - if c_call_error == GRPC_CALL_OK: - call_state.due.add(tag) - return True - else: - _raise_call_error_no_metadata(c_call_error) - else: - return False - - -cdef _cancel( - _ChannelState channel_state, _CallState call_state, grpc_status_code code, - str details): - cdef grpc_call_error c_call_error - with channel_state.condition: - if call_state.due: - c_call_error = grpc_call_cancel_with_status( - call_state.c_call, code, _encode(details), NULL) - _check_and_raise_call_error_no_metadata(c_call_error) - - + + +cdef tuple _operate(grpc_call *c_call, object operations, object user_tag): + cdef grpc_call_error c_call_error + cdef _BatchOperationTag tag = _BatchOperationTag(user_tag, operations, None) + tag.prepare() + cpython.Py_INCREF(tag) + with nogil: + c_call_error = grpc_call_start_batch( + c_call, tag.c_ops, tag.c_nops, <cpython.PyObject *>tag, NULL) + return c_call_error, tag + + +cdef object _operate_from_integrated_call( + _ChannelState channel_state, _CallState call_state, object operations, + object user_tag): + cdef grpc_call_error c_call_error + cdef _BatchOperationTag tag + with channel_state.condition: + if call_state.due: + c_call_error, tag = _operate(call_state.c_call, operations, user_tag) + if c_call_error == GRPC_CALL_OK: + call_state.due.add(tag) + channel_state.integrated_call_states[tag] = call_state + return True + else: + _raise_call_error_no_metadata(c_call_error) + else: + return False + + +cdef object _operate_from_segregated_call( + _ChannelState channel_state, _CallState call_state, object operations, + object user_tag): + cdef grpc_call_error c_call_error + cdef _BatchOperationTag tag + with channel_state.condition: + if call_state.due: + c_call_error, tag = _operate(call_state.c_call, operations, user_tag) + if c_call_error == GRPC_CALL_OK: + call_state.due.add(tag) + return True + else: + _raise_call_error_no_metadata(c_call_error) + else: + return False + + +cdef _cancel( + _ChannelState channel_state, _CallState call_state, grpc_status_code code, + str details): + cdef grpc_call_error c_call_error + with channel_state.condition: + if call_state.due: + c_call_error = grpc_call_cancel_with_status( + call_state.c_call, code, _encode(details), NULL) + _check_and_raise_call_error_no_metadata(c_call_error) + + cdef _next_call_event( - _ChannelState channel_state, grpc_completion_queue *c_completion_queue, + _ChannelState channel_state, grpc_completion_queue *c_completion_queue, on_success, on_failure, deadline): """Block on the next event out of the completion queue. - + On success, `on_success` will be invoked with the tag taken from the CQ. In the case of a failure due to an exception raised in a signal handler, `on_failure` will be invoked with no arguments. Note that this situation can only occur on the main thread. - + Args: channel_state: The state for the channel on which the RPC is running. c_completion_queue: The CQ which will be polled. @@ -174,160 +174,160 @@ cdef _next_call_event( return event -# TODO(https://github.com/grpc/grpc/issues/14569): This could be a lot simpler. -cdef void _call( - _ChannelState channel_state, _CallState call_state, - grpc_completion_queue *c_completion_queue, on_success, int flags, method, - host, object deadline, CallCredentials credentials, +# TODO(https://github.com/grpc/grpc/issues/14569): This could be a lot simpler. +cdef void _call( + _ChannelState channel_state, _CallState call_state, + grpc_completion_queue *c_completion_queue, on_success, int flags, method, + host, object deadline, CallCredentials credentials, object operationses_and_user_tags, object metadata, object context) except *: - """Invokes an RPC. - - Args: - channel_state: A _ChannelState with its "open" attribute set to True. RPCs - may not be invoked on a closed channel. - call_state: An empty _CallState to be altered (specifically assigned a - c_call and having its due set populated) if the RPC invocation is - successful. - c_completion_queue: A grpc_completion_queue to be used for the call's - operations. - on_success: A behavior to be called if attempting to start operations for - the call succeeds. If called the behavior will be called while holding the - channel_state condition and passed the tags associated with operations - that were successfully started for the call. - flags: Flags to be passed to gRPC Core as part of call creation. - method: The fully-qualified name of the RPC method being invoked. - host: A "host" string to be passed to gRPC Core as part of call creation. - deadline: A float for the deadline of the RPC, or None if the RPC is to have - no deadline. - credentials: A _CallCredentials for the RPC or None. - operationses_and_user_tags: A sequence of length-two sequences the first - element of which is a sequence of Operations and the second element of - which is an object to be used as a tag. A SendInitialMetadataOperation - must be present in the first element of this value. - metadata: The metadata for this call. + """Invokes an RPC. + + Args: + channel_state: A _ChannelState with its "open" attribute set to True. RPCs + may not be invoked on a closed channel. + call_state: An empty _CallState to be altered (specifically assigned a + c_call and having its due set populated) if the RPC invocation is + successful. + c_completion_queue: A grpc_completion_queue to be used for the call's + operations. + on_success: A behavior to be called if attempting to start operations for + the call succeeds. If called the behavior will be called while holding the + channel_state condition and passed the tags associated with operations + that were successfully started for the call. + flags: Flags to be passed to gRPC Core as part of call creation. + method: The fully-qualified name of the RPC method being invoked. + host: A "host" string to be passed to gRPC Core as part of call creation. + deadline: A float for the deadline of the RPC, or None if the RPC is to have + no deadline. + credentials: A _CallCredentials for the RPC or None. + operationses_and_user_tags: A sequence of length-two sequences the first + element of which is a sequence of Operations and the second element of + which is an object to be used as a tag. A SendInitialMetadataOperation + must be present in the first element of this value. + metadata: The metadata for this call. context: Context object for distributed tracing. - """ - cdef grpc_slice method_slice - cdef grpc_slice host_slice - cdef grpc_slice *host_slice_ptr - cdef grpc_call_credentials *c_call_credentials - cdef grpc_call_error c_call_error - cdef tuple error_and_wrapper_tag - cdef _BatchOperationTag wrapper_tag - with channel_state.condition: - if channel_state.open: - method_slice = _slice_from_bytes(method) - if host is None: - host_slice_ptr = NULL - else: - host_slice = _slice_from_bytes(host) - host_slice_ptr = &host_slice - call_state.c_call = grpc_channel_create_call( - channel_state.c_channel, NULL, flags, - c_completion_queue, method_slice, host_slice_ptr, - _timespec_from_time(deadline), NULL) - grpc_slice_unref(method_slice) - if host_slice_ptr: - grpc_slice_unref(host_slice) + """ + cdef grpc_slice method_slice + cdef grpc_slice host_slice + cdef grpc_slice *host_slice_ptr + cdef grpc_call_credentials *c_call_credentials + cdef grpc_call_error c_call_error + cdef tuple error_and_wrapper_tag + cdef _BatchOperationTag wrapper_tag + with channel_state.condition: + if channel_state.open: + method_slice = _slice_from_bytes(method) + if host is None: + host_slice_ptr = NULL + else: + host_slice = _slice_from_bytes(host) + host_slice_ptr = &host_slice + call_state.c_call = grpc_channel_create_call( + channel_state.c_channel, NULL, flags, + c_completion_queue, method_slice, host_slice_ptr, + _timespec_from_time(deadline), NULL) + grpc_slice_unref(method_slice) + if host_slice_ptr: + grpc_slice_unref(host_slice) if context is not None: set_census_context_on_call(call_state, context) - if credentials is not None: - c_call_credentials = credentials.c() - c_call_error = grpc_call_set_credentials( - call_state.c_call, c_call_credentials) - grpc_call_credentials_release(c_call_credentials) - if c_call_error != GRPC_CALL_OK: - grpc_call_unref(call_state.c_call) - call_state.c_call = NULL - _raise_call_error_no_metadata(c_call_error) - started_tags = set() - for operations, user_tag in operationses_and_user_tags: - c_call_error, tag = _operate(call_state.c_call, operations, user_tag) - if c_call_error == GRPC_CALL_OK: - started_tags.add(tag) - else: - grpc_call_cancel(call_state.c_call, NULL) - grpc_call_unref(call_state.c_call) - call_state.c_call = NULL - _raise_call_error(c_call_error, metadata) - else: - call_state.due.update(started_tags) - on_success(started_tags) - else: + if credentials is not None: + c_call_credentials = credentials.c() + c_call_error = grpc_call_set_credentials( + call_state.c_call, c_call_credentials) + grpc_call_credentials_release(c_call_credentials) + if c_call_error != GRPC_CALL_OK: + grpc_call_unref(call_state.c_call) + call_state.c_call = NULL + _raise_call_error_no_metadata(c_call_error) + started_tags = set() + for operations, user_tag in operationses_and_user_tags: + c_call_error, tag = _operate(call_state.c_call, operations, user_tag) + if c_call_error == GRPC_CALL_OK: + started_tags.add(tag) + else: + grpc_call_cancel(call_state.c_call, NULL) + grpc_call_unref(call_state.c_call) + call_state.c_call = NULL + _raise_call_error(c_call_error, metadata) + else: + call_state.due.update(started_tags) + on_success(started_tags) + else: raise ValueError('Cannot invoke RPC: %s' % channel_state.closed_reason) -cdef void _process_integrated_call_tag( - _ChannelState state, _BatchOperationTag tag) except *: - cdef _CallState call_state = state.integrated_call_states.pop(tag) - call_state.due.remove(tag) - if not call_state.due: - grpc_call_unref(call_state.c_call) - call_state.c_call = NULL - - -cdef class IntegratedCall: - - def __cinit__(self, _ChannelState channel_state, _CallState call_state): - self._channel_state = channel_state - self._call_state = call_state - - def operate(self, operations, tag): - return _operate_from_integrated_call( - self._channel_state, self._call_state, operations, tag) - - def cancel(self, code, details): - _cancel(self._channel_state, self._call_state, code, details) - - -cdef IntegratedCall _integrated_call( - _ChannelState state, int flags, method, host, object deadline, +cdef void _process_integrated_call_tag( + _ChannelState state, _BatchOperationTag tag) except *: + cdef _CallState call_state = state.integrated_call_states.pop(tag) + call_state.due.remove(tag) + if not call_state.due: + grpc_call_unref(call_state.c_call) + call_state.c_call = NULL + + +cdef class IntegratedCall: + + def __cinit__(self, _ChannelState channel_state, _CallState call_state): + self._channel_state = channel_state + self._call_state = call_state + + def operate(self, operations, tag): + return _operate_from_integrated_call( + self._channel_state, self._call_state, operations, tag) + + def cancel(self, code, details): + _cancel(self._channel_state, self._call_state, code, details) + + +cdef IntegratedCall _integrated_call( + _ChannelState state, int flags, method, host, object deadline, object metadata, CallCredentials credentials, operationses_and_user_tags, object context): - call_state = _CallState() - - def on_success(started_tags): - for started_tag in started_tags: - state.integrated_call_states[started_tag] = call_state - - _call( - state, call_state, state.c_call_completion_queue, on_success, flags, + call_state = _CallState() + + def on_success(started_tags): + for started_tag in started_tags: + state.integrated_call_states[started_tag] = call_state + + _call( + state, call_state, state.c_call_completion_queue, on_success, flags, method, host, deadline, credentials, operationses_and_user_tags, metadata, context) - - return IntegratedCall(state, call_state) - - -cdef object _process_segregated_call_tag( - _ChannelState state, _CallState call_state, - grpc_completion_queue *c_completion_queue, _BatchOperationTag tag): - call_state.due.remove(tag) - if not call_state.due: - grpc_call_unref(call_state.c_call) - call_state.c_call = NULL - state.segregated_call_states.remove(call_state) - _destroy_c_completion_queue(c_completion_queue) - return True - else: - return False - - -cdef class SegregatedCall: - - def __cinit__(self, _ChannelState channel_state, _CallState call_state): - self._channel_state = channel_state - self._call_state = call_state - - def operate(self, operations, tag): - return _operate_from_segregated_call( - self._channel_state, self._call_state, operations, tag) - - def cancel(self, code, details): - _cancel(self._channel_state, self._call_state, code, details) - - def next_event(self): - def on_success(tag): - _process_segregated_call_tag( + + return IntegratedCall(state, call_state) + + +cdef object _process_segregated_call_tag( + _ChannelState state, _CallState call_state, + grpc_completion_queue *c_completion_queue, _BatchOperationTag tag): + call_state.due.remove(tag) + if not call_state.due: + grpc_call_unref(call_state.c_call) + call_state.c_call = NULL + state.segregated_call_states.remove(call_state) + _destroy_c_completion_queue(c_completion_queue) + return True + else: + return False + + +cdef class SegregatedCall: + + def __cinit__(self, _ChannelState channel_state, _CallState call_state): + self._channel_state = channel_state + self._call_state = call_state + + def operate(self, operations, tag): + return _operate_from_segregated_call( + self._channel_state, self._call_state, operations, tag) + + def cancel(self, code, details): + _cancel(self._channel_state, self._call_state, code, details) + + def next_event(self): + def on_success(tag): + _process_segregated_call_tag( self._channel_state, self._call_state, self._c_completion_queue, tag) def on_failure(): self._call_state.due.clear() @@ -335,80 +335,80 @@ cdef class SegregatedCall: self._call_state.c_call = NULL self._channel_state.segregated_call_states.remove(self._call_state) _destroy_c_completion_queue(self._c_completion_queue) - return _next_call_event( + return _next_call_event( self._channel_state, self._c_completion_queue, on_success, on_failure, None) - - -cdef SegregatedCall _segregated_call( - _ChannelState state, int flags, method, host, object deadline, + + +cdef SegregatedCall _segregated_call( + _ChannelState state, int flags, method, host, object deadline, object metadata, CallCredentials credentials, operationses_and_user_tags, object context): - cdef _CallState call_state = _CallState() - cdef SegregatedCall segregated_call + cdef _CallState call_state = _CallState() + cdef SegregatedCall segregated_call cdef grpc_completion_queue *c_completion_queue - - def on_success(started_tags): - state.segregated_call_states.add(call_state) - + + def on_success(started_tags): + state.segregated_call_states.add(call_state) + with state.condition: if state.open: c_completion_queue = (grpc_completion_queue_create_for_next(NULL)) else: raise ValueError('Cannot invoke RPC on closed channel!') - try: - _call( - state, call_state, c_completion_queue, on_success, flags, method, host, + try: + _call( + state, call_state, c_completion_queue, on_success, flags, method, host, deadline, credentials, operationses_and_user_tags, metadata, context) - except: - _destroy_c_completion_queue(c_completion_queue) - raise - - segregated_call = SegregatedCall(state, call_state) - segregated_call._c_completion_queue = c_completion_queue - return segregated_call - - -cdef object _watch_connectivity_state( - _ChannelState state, grpc_connectivity_state last_observed_state, - object deadline): - cdef _ConnectivityTag tag = _ConnectivityTag(object()) - with state.condition: - if state.open: - cpython.Py_INCREF(tag) - grpc_channel_watch_connectivity_state( - state.c_channel, last_observed_state, _timespec_from_time(deadline), - state.c_connectivity_completion_queue, <cpython.PyObject *>tag) - state.connectivity_due.add(tag) - else: + except: + _destroy_c_completion_queue(c_completion_queue) + raise + + segregated_call = SegregatedCall(state, call_state) + segregated_call._c_completion_queue = c_completion_queue + return segregated_call + + +cdef object _watch_connectivity_state( + _ChannelState state, grpc_connectivity_state last_observed_state, + object deadline): + cdef _ConnectivityTag tag = _ConnectivityTag(object()) + with state.condition: + if state.open: + cpython.Py_INCREF(tag) + grpc_channel_watch_connectivity_state( + state.c_channel, last_observed_state, _timespec_from_time(deadline), + state.c_connectivity_completion_queue, <cpython.PyObject *>tag) + state.connectivity_due.add(tag) + else: raise ValueError('Cannot invoke RPC: %s' % state.closed_reason) - completed_tag, event = _latent_event( - state.c_connectivity_completion_queue, None) - with state.condition: - state.connectivity_due.remove(completed_tag) - state.condition.notify_all() - return event - - + completed_tag, event = _latent_event( + state.c_connectivity_completion_queue, None) + with state.condition: + state.connectivity_due.remove(completed_tag) + state.condition.notify_all() + return event + + cdef _close(Channel channel, grpc_status_code code, object details, drain_calls): cdef _ChannelState state = channel._state - cdef _CallState call_state - encoded_details = _encode(details) - with state.condition: - if state.open: - state.open = False + cdef _CallState call_state + encoded_details = _encode(details) + with state.condition: + if state.open: + state.open = False state.closed_reason = details - for call_state in set(state.integrated_call_states.values()): - grpc_call_cancel_with_status( - call_state.c_call, code, encoded_details, NULL) - for call_state in state.segregated_call_states: - grpc_call_cancel_with_status( - call_state.c_call, code, encoded_details, NULL) - # TODO(https://github.com/grpc/grpc/issues/3064): Cancel connectivity - # watching. - + for call_state in set(state.integrated_call_states.values()): + grpc_call_cancel_with_status( + call_state.c_call, code, encoded_details, NULL) + for call_state in state.segregated_call_states: + grpc_call_cancel_with_status( + call_state.c_call, code, encoded_details, NULL) + # TODO(https://github.com/grpc/grpc/issues/3064): Cancel connectivity + # watching. + if drain_calls: while not _calls_drained(state): event = channel.next_call_event() @@ -420,32 +420,32 @@ cdef _close(Channel channel, grpc_status_code code, object details, state.condition.wait() while state.connectivity_due: state.condition.wait() - - _destroy_c_completion_queue(state.c_call_completion_queue) - _destroy_c_completion_queue(state.c_connectivity_completion_queue) - grpc_channel_destroy(state.c_channel) - state.c_channel = NULL + + _destroy_c_completion_queue(state.c_call_completion_queue) + _destroy_c_completion_queue(state.c_connectivity_completion_queue) + grpc_channel_destroy(state.c_channel) + state.c_channel = NULL grpc_shutdown_blocking() - state.condition.notify_all() - else: - # Another call to close already completed in the past or is currently - # being executed in another thread. - while state.c_channel != NULL: - state.condition.wait() - - + state.condition.notify_all() + else: + # Another call to close already completed in the past or is currently + # being executed in another thread. + while state.c_channel != NULL: + state.condition.wait() + + cdef _calls_drained(_ChannelState state): return not (state.integrated_call_states or state.segregated_call_states or state.connectivity_due) cdef class Channel: - def __cinit__( - self, bytes target, object arguments, - ChannelCredentials channel_credentials): + def __cinit__( + self, bytes target, object arguments, + ChannelCredentials channel_credentials): arguments = () if arguments is None else tuple(arguments) fork_handlers_and_grpc_init() - self._state = _ChannelState() + self._state = _ChannelState() self._state.c_call_completion_queue = ( grpc_completion_queue_create_for_next(NULL)) self._state.c_connectivity_completion_queue = ( @@ -453,32 +453,32 @@ cdef class Channel: self._arguments = arguments cdef _ChannelArgs channel_args = _ChannelArgs(arguments) if channel_credentials is None: - self._state.c_channel = grpc_insecure_channel_create( + self._state.c_channel = grpc_insecure_channel_create( <char *>target, channel_args.c_args(), NULL) else: - c_channel_credentials = channel_credentials.c() - self._state.c_channel = grpc_secure_channel_create( + c_channel_credentials = channel_credentials.c() + self._state.c_channel = grpc_secure_channel_create( c_channel_credentials, <char *>target, channel_args.c_args(), NULL) - grpc_channel_credentials_release(c_channel_credentials) - - def target(self): - cdef char *c_target - with self._state.condition: - c_target = grpc_channel_get_target(self._state.c_channel) - target = <bytes>c_target - gpr_free(c_target) - return target - - def integrated_call( - self, int flags, method, host, object deadline, object metadata, + grpc_channel_credentials_release(c_channel_credentials) + + def target(self): + cdef char *c_target + with self._state.condition: + c_target = grpc_channel_get_target(self._state.c_channel) + target = <bytes>c_target + gpr_free(c_target) + return target + + def integrated_call( + self, int flags, method, host, object deadline, object metadata, CallCredentials credentials, operationses_and_tags, object context = None): - return _integrated_call( - self._state, flags, method, host, deadline, metadata, credentials, + return _integrated_call( + self._state, flags, method, host, deadline, metadata, credentials, operationses_and_tags, context) - - def next_call_event(self): - def on_success(tag): + + def next_call_event(self): + def on_success(tag): if tag is not None: _process_integrated_call_tag(self._state, tag) if is_fork_support_enabled(): @@ -490,17 +490,17 @@ cdef class Channel: # method is only ever invoked on the channel spin thread. return _next_call_event(self._state, self._state.c_call_completion_queue, on_success, None, queue_deadline) - - def segregated_call( - self, int flags, method, host, object deadline, object metadata, + + def segregated_call( + self, int flags, method, host, object deadline, object metadata, CallCredentials credentials, operationses_and_tags, object context = None): - return _segregated_call( - self._state, flags, method, host, deadline, metadata, credentials, + return _segregated_call( + self._state, flags, method, host, deadline, metadata, credentials, operationses_and_tags, context) - + def check_connectivity_state(self, bint try_to_connect): - with self._state.condition: + with self._state.condition: if self._state.open: return grpc_channel_check_connectivity_state( self._state.c_channel, try_to_connect) @@ -508,10 +508,10 @@ cdef class Channel: raise ValueError('Cannot invoke RPC: %s' % self._state.closed_reason) def watch_connectivity_state( - self, grpc_connectivity_state last_observed_state, object deadline): - return _watch_connectivity_state(self._state, last_observed_state, deadline) + self, grpc_connectivity_state last_observed_state, object deadline): + return _watch_connectivity_state(self._state, last_observed_state, deadline) - def close(self, code, details): + def close(self, code, details): _close(self, code, details, False) def close_on_fork(self, code, details): diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi index 0307f74cbe..258b84363b 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pxd.pxi @@ -1,28 +1,28 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef grpc_event _next(grpc_completion_queue *c_completion_queue, deadline) except * - - -cdef _interpret_event(grpc_event c_event) - - + + +cdef _interpret_event(grpc_event c_event) + + cdef class CompletionQueue: cdef grpc_completion_queue *c_completion_queue cdef bint is_shutting_down cdef bint is_shutdown - cdef _interpret_event(self, grpc_event c_event) + cdef _interpret_event(self, grpc_event c_event) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi index a47403ac51..7b7e6f5c0a 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi @@ -1,95 +1,95 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef int _INTERRUPT_CHECK_PERIOD_MS = 200 cdef grpc_event _next(grpc_completion_queue *c_completion_queue, deadline) except *: - cdef gpr_timespec c_increment - cdef gpr_timespec c_timeout - cdef gpr_timespec c_deadline - c_increment = gpr_time_from_millis(_INTERRUPT_CHECK_PERIOD_MS, GPR_TIMESPAN) - if deadline is None: - c_deadline = gpr_inf_future(GPR_CLOCK_REALTIME) - else: - c_deadline = _timespec_from_time(deadline) - + cdef gpr_timespec c_increment + cdef gpr_timespec c_timeout + cdef gpr_timespec c_deadline + c_increment = gpr_time_from_millis(_INTERRUPT_CHECK_PERIOD_MS, GPR_TIMESPAN) + if deadline is None: + c_deadline = gpr_inf_future(GPR_CLOCK_REALTIME) + else: + c_deadline = _timespec_from_time(deadline) + while True: with nogil: - c_timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c_increment) - if gpr_time_cmp(c_timeout, c_deadline) > 0: - c_timeout = c_deadline + c_timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c_increment) + if gpr_time_cmp(c_timeout, c_deadline) > 0: + c_timeout = c_deadline - c_event = grpc_completion_queue_next(c_completion_queue, c_timeout, NULL) + c_event = grpc_completion_queue_next(c_completion_queue, c_timeout, NULL) - if (c_event.type != GRPC_QUEUE_TIMEOUT or - gpr_time_cmp(c_timeout, c_deadline) == 0): - break - + if (c_event.type != GRPC_QUEUE_TIMEOUT or + gpr_time_cmp(c_timeout, c_deadline) == 0): + break + # Handle any signals cpython.PyErr_CheckSignals() - return c_event - - -cdef _interpret_event(grpc_event c_event): - cdef _Tag tag - if c_event.type == GRPC_QUEUE_TIMEOUT: + return c_event + + +cdef _interpret_event(grpc_event c_event): + cdef _Tag tag + if c_event.type == GRPC_QUEUE_TIMEOUT: # TODO(ericgribkoff) Do not coopt ConnectivityEvent here. - return None, ConnectivityEvent(GRPC_QUEUE_TIMEOUT, False, None) - elif c_event.type == GRPC_QUEUE_SHUTDOWN: - # NOTE(nathaniel): For now we coopt ConnectivityEvent here. - return None, ConnectivityEvent(GRPC_QUEUE_SHUTDOWN, False, None) - else: - tag = <_Tag>c_event.tag - # We receive event tags only after they've been inc-ref'd elsewhere in - # the code. - cpython.Py_DECREF(tag) - return tag, tag.event(c_event) - - -cdef _latent_event(grpc_completion_queue *c_completion_queue, object deadline): - cdef grpc_event c_event = _next(c_completion_queue, deadline) - return _interpret_event(c_event) - - + return None, ConnectivityEvent(GRPC_QUEUE_TIMEOUT, False, None) + elif c_event.type == GRPC_QUEUE_SHUTDOWN: + # NOTE(nathaniel): For now we coopt ConnectivityEvent here. + return None, ConnectivityEvent(GRPC_QUEUE_SHUTDOWN, False, None) + else: + tag = <_Tag>c_event.tag + # We receive event tags only after they've been inc-ref'd elsewhere in + # the code. + cpython.Py_DECREF(tag) + return tag, tag.event(c_event) + + +cdef _latent_event(grpc_completion_queue *c_completion_queue, object deadline): + cdef grpc_event c_event = _next(c_completion_queue, deadline) + return _interpret_event(c_event) + + cdef class CompletionQueue: - def __cinit__(self, shutdown_cq=False): - cdef grpc_completion_queue_attributes c_attrs + def __cinit__(self, shutdown_cq=False): + cdef grpc_completion_queue_attributes c_attrs fork_handlers_and_grpc_init() - if shutdown_cq: - c_attrs.version = 1 - c_attrs.cq_completion_type = GRPC_CQ_NEXT - c_attrs.cq_polling_type = GRPC_CQ_NON_LISTENING - self.c_completion_queue = grpc_completion_queue_create( - grpc_completion_queue_factory_lookup(&c_attrs), &c_attrs, NULL); - else: - self.c_completion_queue = grpc_completion_queue_create_for_next(NULL) + if shutdown_cq: + c_attrs.version = 1 + c_attrs.cq_completion_type = GRPC_CQ_NEXT + c_attrs.cq_polling_type = GRPC_CQ_NON_LISTENING + self.c_completion_queue = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&c_attrs), &c_attrs, NULL); + else: + self.c_completion_queue = grpc_completion_queue_create_for_next(NULL) self.is_shutting_down = False self.is_shutdown = False - cdef _interpret_event(self, grpc_event c_event): - unused_tag, event = _interpret_event(c_event) - if event.completion_type == GRPC_QUEUE_SHUTDOWN: + cdef _interpret_event(self, grpc_event c_event): + unused_tag, event = _interpret_event(c_event) + if event.completion_type == GRPC_QUEUE_SHUTDOWN: self.is_shutdown = True - return event + return event - # We name this 'poll' to avoid problems with CPython's expectations for - # 'special' methods (like next and __next__). - def poll(self, deadline=None): - return self._interpret_event(_next(self.c_completion_queue, deadline)) + # We name this 'poll' to avoid problems with CPython's expectations for + # 'special' methods (like next and __next__). + def poll(self, deadline=None): + return self._interpret_event(_next(self.c_completion_queue, deadline)) def shutdown(self): with nogil: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi index ddaedb30bd..cbb55c6cf8 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pxd.pxi @@ -1,102 +1,102 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -cdef class CallCredentials: +cdef class CallCredentials: cdef grpc_call_credentials *c(self) except * - - # TODO(https://github.com/grpc/grpc/issues/12531): remove. - cdef grpc_call_credentials *c_credentials - - -cdef int _get_metadata( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, - grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, + + # TODO(https://github.com/grpc/grpc/issues/12531): remove. + cdef grpc_call_credentials *c_credentials + + +cdef int _get_metadata( + void *state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void *user_data, + grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], + size_t *num_creds_md, grpc_status_code *status, const char **error_details) except * with gil - + cdef void _destroy(void *state) except * with gil - - -cdef class MetadataPluginCallCredentials(CallCredentials): - - cdef readonly object _metadata_plugin - cdef readonly bytes _name - + + +cdef class MetadataPluginCallCredentials(CallCredentials): + + cdef readonly object _metadata_plugin + cdef readonly bytes _name + cdef grpc_call_credentials *c(self) except * - - -cdef grpc_call_credentials *_composition(call_credentialses) - - -cdef class CompositeCallCredentials(CallCredentials): - - cdef readonly tuple _call_credentialses - + + +cdef grpc_call_credentials *_composition(call_credentialses) + + +cdef class CompositeCallCredentials(CallCredentials): + + cdef readonly tuple _call_credentialses + cdef grpc_call_credentials *c(self) except * - - + + cdef class ChannelCredentials: cdef grpc_channel_credentials *c(self) except * - + cdef class SSLSessionCacheLRU: cdef grpc_ssl_session_cache *_cache -cdef class SSLChannelCredentials(ChannelCredentials): +cdef class SSLChannelCredentials(ChannelCredentials): - cdef readonly object _pem_root_certificates - cdef readonly object _private_key - cdef readonly object _certificate_chain + cdef readonly object _pem_root_certificates + cdef readonly object _private_key + cdef readonly object _certificate_chain cdef grpc_channel_credentials *c(self) except * -cdef class CompositeChannelCredentials(ChannelCredentials): +cdef class CompositeChannelCredentials(ChannelCredentials): - cdef readonly tuple _call_credentialses - cdef readonly ChannelCredentials _channel_credentials + cdef readonly tuple _call_credentialses + cdef readonly ChannelCredentials _channel_credentials cdef grpc_channel_credentials *c(self) except * -cdef class ServerCertificateConfig: +cdef class ServerCertificateConfig: - cdef grpc_ssl_server_certificate_config *c_cert_config - cdef const char *c_pem_root_certs - cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs - cdef size_t c_ssl_pem_key_cert_pairs_count - cdef list references + cdef grpc_ssl_server_certificate_config *c_cert_config + cdef const char *c_pem_root_certs + cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs + cdef size_t c_ssl_pem_key_cert_pairs_count + cdef list references -cdef class ServerCredentials: +cdef class ServerCredentials: - cdef grpc_server_credentials *c_credentials - cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs - cdef size_t c_ssl_pem_key_cert_pairs_count - cdef list references - # the cert config related state is used only if this credentials is - # created with cert config/fetcher - cdef object initial_cert_config - cdef object cert_config_fetcher - # whether C-core has asked for the initial_cert_config - cdef bint initial_cert_config_fetched + cdef grpc_server_credentials *c_credentials + cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs + cdef size_t c_ssl_pem_key_cert_pairs_count + cdef list references + # the cert config related state is used only if this credentials is + # created with cert config/fetcher + cdef object initial_cert_config + cdef object cert_config_fetcher + # whether C-core has asked for the initial_cert_config + cdef bint initial_cert_config_fetched cdef class LocalChannelCredentials(ChannelCredentials): diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index c75579cc04..11c00bcf43 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. def _spawn_callback_in_thread(cb_func, args): @@ -28,10 +28,10 @@ def _spawn_callback_async(callback, args): async_callback_func(callback, args) -cdef class CallCredentials: +cdef class CallCredentials: cdef grpc_call_credentials *c(self) except *: - raise NotImplementedError() + raise NotImplementedError() cdef int _get_metadata(void *state, @@ -42,74 +42,74 @@ cdef int _get_metadata(void *state, size_t *num_creds_md, grpc_status_code *status, const char **error_details) except * with gil: - cdef size_t metadata_count - cdef grpc_metadata *c_metadata - def callback(metadata, grpc_status_code status, bytes error_details): + cdef size_t metadata_count + cdef grpc_metadata *c_metadata + def callback(metadata, grpc_status_code status, bytes error_details): if status == StatusCode.ok: - _store_c_metadata(metadata, &c_metadata, &metadata_count) - cb(user_data, c_metadata, metadata_count, status, NULL) - _release_c_metadata(c_metadata, metadata_count) - else: - cb(user_data, NULL, 0, status, error_details) - args = context.service_url, context.method_name, callback, + _store_c_metadata(metadata, &c_metadata, &metadata_count) + cb(user_data, c_metadata, metadata_count, status, NULL) + _release_c_metadata(c_metadata, metadata_count) + else: + cb(user_data, NULL, 0, status, error_details) + args = context.service_url, context.method_name, callback, _spawn_callback_async(<object>state, args) - return 0 # Asynchronous return + return 0 # Asynchronous return cdef void _destroy(void *state) except * with gil: - cpython.Py_DECREF(<object>state) + cpython.Py_DECREF(<object>state) grpc_shutdown_blocking() -cdef class MetadataPluginCallCredentials(CallCredentials): +cdef class MetadataPluginCallCredentials(CallCredentials): - def __cinit__(self, metadata_plugin, name): - self._metadata_plugin = metadata_plugin - self._name = name + def __cinit__(self, metadata_plugin, name): + self._metadata_plugin = metadata_plugin + self._name = name cdef grpc_call_credentials *c(self) except *: - cdef grpc_metadata_credentials_plugin c_metadata_plugin - c_metadata_plugin.get_metadata = _get_metadata - c_metadata_plugin.destroy = _destroy - c_metadata_plugin.state = <void *>self._metadata_plugin - c_metadata_plugin.type = self._name - cpython.Py_INCREF(self._metadata_plugin) + cdef grpc_metadata_credentials_plugin c_metadata_plugin + c_metadata_plugin.get_metadata = _get_metadata + c_metadata_plugin.destroy = _destroy + c_metadata_plugin.state = <void *>self._metadata_plugin + c_metadata_plugin.type = self._name + cpython.Py_INCREF(self._metadata_plugin) fork_handlers_and_grpc_init() # TODO(yihuazhang): Expose min_security_level via the Python API so that # applications can decide what minimum security level their plugins require. return grpc_metadata_credentials_create_from_plugin(c_metadata_plugin, GRPC_PRIVACY_AND_INTEGRITY, NULL) -cdef grpc_call_credentials *_composition(call_credentialses): - call_credentials_iterator = iter(call_credentialses) - cdef CallCredentials composition = next(call_credentials_iterator) - cdef grpc_call_credentials *c_composition = composition.c() - cdef CallCredentials additional_call_credentials - cdef grpc_call_credentials *c_additional_call_credentials - cdef grpc_call_credentials *c_next_composition - for additional_call_credentials in call_credentials_iterator: - c_additional_call_credentials = additional_call_credentials.c() - c_next_composition = grpc_composite_call_credentials_create( - c_composition, c_additional_call_credentials, NULL) - grpc_call_credentials_release(c_composition) - grpc_call_credentials_release(c_additional_call_credentials) - c_composition = c_next_composition - return c_composition +cdef grpc_call_credentials *_composition(call_credentialses): + call_credentials_iterator = iter(call_credentialses) + cdef CallCredentials composition = next(call_credentials_iterator) + cdef grpc_call_credentials *c_composition = composition.c() + cdef CallCredentials additional_call_credentials + cdef grpc_call_credentials *c_additional_call_credentials + cdef grpc_call_credentials *c_next_composition + for additional_call_credentials in call_credentials_iterator: + c_additional_call_credentials = additional_call_credentials.c() + c_next_composition = grpc_composite_call_credentials_create( + c_composition, c_additional_call_credentials, NULL) + grpc_call_credentials_release(c_composition) + grpc_call_credentials_release(c_additional_call_credentials) + c_composition = c_next_composition + return c_composition -cdef class CompositeCallCredentials(CallCredentials): +cdef class CompositeCallCredentials(CallCredentials): - def __cinit__(self, call_credentialses): - self._call_credentialses = call_credentialses + def __cinit__(self, call_credentialses): + self._call_credentialses = call_credentialses cdef grpc_call_credentials *c(self) except *: - return _composition(self._call_credentialses) + return _composition(self._call_credentialses) -cdef class ChannelCredentials: +cdef class ChannelCredentials: cdef grpc_channel_credentials *c(self) except *: - raise NotImplementedError() + raise NotImplementedError() cdef class SSLSessionCacheLRU: @@ -127,26 +127,26 @@ cdef class SSLSessionCacheLRU: grpc_shutdown_blocking() -cdef class SSLChannelCredentials(ChannelCredentials): +cdef class SSLChannelCredentials(ChannelCredentials): - def __cinit__(self, pem_root_certificates, private_key, certificate_chain): + def __cinit__(self, pem_root_certificates, private_key, certificate_chain): if pem_root_certificates is not None and not isinstance(pem_root_certificates, bytes): raise TypeError('expected certificate to be bytes, got %s' % (type(pem_root_certificates))) - self._pem_root_certificates = pem_root_certificates - self._private_key = private_key - self._certificate_chain = certificate_chain + self._pem_root_certificates = pem_root_certificates + self._private_key = private_key + self._certificate_chain = certificate_chain cdef grpc_channel_credentials *c(self) except *: - cdef const char *c_pem_root_certificates - cdef grpc_ssl_pem_key_cert_pair c_pem_key_certificate_pair - if self._pem_root_certificates is None: - c_pem_root_certificates = NULL - else: - c_pem_root_certificates = self._pem_root_certificates - if self._private_key is None and self._certificate_chain is None: - return grpc_ssl_credentials_create( + cdef const char *c_pem_root_certificates + cdef grpc_ssl_pem_key_cert_pair c_pem_key_certificate_pair + if self._pem_root_certificates is None: + c_pem_root_certificates = NULL + else: + c_pem_root_certificates = self._pem_root_certificates + if self._private_key is None and self._certificate_chain is None: + return grpc_ssl_credentials_create( c_pem_root_certificates, NULL, NULL, NULL) - else: + else: if self._private_key: c_pem_key_certificate_pair.private_key = self._private_key else: @@ -155,142 +155,142 @@ cdef class SSLChannelCredentials(ChannelCredentials): c_pem_key_certificate_pair.certificate_chain = self._certificate_chain else: c_pem_key_certificate_pair.certificate_chain = NULL - return grpc_ssl_credentials_create( + return grpc_ssl_credentials_create( c_pem_root_certificates, &c_pem_key_certificate_pair, NULL, NULL) -cdef class CompositeChannelCredentials(ChannelCredentials): +cdef class CompositeChannelCredentials(ChannelCredentials): - def __cinit__(self, call_credentialses, channel_credentials): - self._call_credentialses = call_credentialses - self._channel_credentials = channel_credentials + def __cinit__(self, call_credentialses, channel_credentials): + self._call_credentialses = call_credentialses + self._channel_credentials = channel_credentials cdef grpc_channel_credentials *c(self) except *: - cdef grpc_channel_credentials *c_channel_credentials - c_channel_credentials = self._channel_credentials.c() - cdef grpc_call_credentials *c_call_credentials_composition = _composition( - self._call_credentialses) - cdef grpc_channel_credentials *composition - c_composition = grpc_composite_channel_credentials_create( - c_channel_credentials, c_call_credentials_composition, NULL) - grpc_channel_credentials_release(c_channel_credentials) - grpc_call_credentials_release(c_call_credentials_composition) - return c_composition + cdef grpc_channel_credentials *c_channel_credentials + c_channel_credentials = self._channel_credentials.c() + cdef grpc_call_credentials *c_call_credentials_composition = _composition( + self._call_credentialses) + cdef grpc_channel_credentials *composition + c_composition = grpc_composite_channel_credentials_create( + c_channel_credentials, c_call_credentials_composition, NULL) + grpc_channel_credentials_release(c_channel_credentials) + grpc_call_credentials_release(c_call_credentials_composition) + return c_composition -cdef class ServerCertificateConfig: +cdef class ServerCertificateConfig: - def __cinit__(self): + def __cinit__(self): fork_handlers_and_grpc_init() - self.c_cert_config = NULL - self.c_pem_root_certs = NULL - self.c_ssl_pem_key_cert_pairs = NULL - self.references = [] - - def __dealloc__(self): - grpc_ssl_server_certificate_config_destroy(self.c_cert_config) - gpr_free(self.c_ssl_pem_key_cert_pairs) + self.c_cert_config = NULL + self.c_pem_root_certs = NULL + self.c_ssl_pem_key_cert_pairs = NULL + self.references = [] + + def __dealloc__(self): + grpc_ssl_server_certificate_config_destroy(self.c_cert_config) + gpr_free(self.c_ssl_pem_key_cert_pairs) grpc_shutdown_blocking() -cdef class ServerCredentials: +cdef class ServerCredentials: - def __cinit__(self): + def __cinit__(self): fork_handlers_and_grpc_init() - self.c_credentials = NULL - self.references = [] - self.initial_cert_config = None - self.cert_config_fetcher = None - self.initial_cert_config_fetched = False - - def __dealloc__(self): - if self.c_credentials != NULL: - grpc_server_credentials_release(self.c_credentials) + self.c_credentials = NULL + self.references = [] + self.initial_cert_config = None + self.cert_config_fetcher = None + self.initial_cert_config_fetched = False + + def __dealloc__(self): + if self.c_credentials != NULL: + grpc_server_credentials_release(self.c_credentials) grpc_shutdown_blocking() -cdef const char* _get_c_pem_root_certs(pem_root_certs): - if pem_root_certs is None: - return NULL - else: - return pem_root_certs - -cdef grpc_ssl_pem_key_cert_pair* _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs): - # return a malloc'ed grpc_ssl_pem_key_cert_pair from a _list_ of SslPemKeyCertPair - for pair in pem_key_cert_pairs: - if not isinstance(pair, SslPemKeyCertPair): - raise TypeError("expected pem_key_cert_pairs to be sequence of " - "SslPemKeyCertPair") - cdef size_t c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs) - cdef grpc_ssl_pem_key_cert_pair* c_ssl_pem_key_cert_pairs = NULL +cdef const char* _get_c_pem_root_certs(pem_root_certs): + if pem_root_certs is None: + return NULL + else: + return pem_root_certs + +cdef grpc_ssl_pem_key_cert_pair* _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs): + # return a malloc'ed grpc_ssl_pem_key_cert_pair from a _list_ of SslPemKeyCertPair + for pair in pem_key_cert_pairs: + if not isinstance(pair, SslPemKeyCertPair): + raise TypeError("expected pem_key_cert_pairs to be sequence of " + "SslPemKeyCertPair") + cdef size_t c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs) + cdef grpc_ssl_pem_key_cert_pair* c_ssl_pem_key_cert_pairs = NULL with nogil: - c_ssl_pem_key_cert_pairs = ( - <grpc_ssl_pem_key_cert_pair *>gpr_malloc( - sizeof(grpc_ssl_pem_key_cert_pair) * c_ssl_pem_key_cert_pairs_count)) - for i in range(c_ssl_pem_key_cert_pairs_count): - c_ssl_pem_key_cert_pairs[i] = ( - (<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair) - return c_ssl_pem_key_cert_pairs + c_ssl_pem_key_cert_pairs = ( + <grpc_ssl_pem_key_cert_pair *>gpr_malloc( + sizeof(grpc_ssl_pem_key_cert_pair) * c_ssl_pem_key_cert_pairs_count)) + for i in range(c_ssl_pem_key_cert_pairs_count): + c_ssl_pem_key_cert_pairs[i] = ( + (<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair) + return c_ssl_pem_key_cert_pairs def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs, bint force_client_auth): pem_root_certs = str_to_bytes(pem_root_certs) pem_key_cert_pairs = list(pem_key_cert_pairs) cdef ServerCredentials credentials = ServerCredentials() - credentials.references.append(pem_root_certs) + credentials.references.append(pem_root_certs) credentials.references.append(pem_key_cert_pairs) - cdef const char * c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs) + cdef const char * c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs) credentials.c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs) - credentials.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs) - cdef grpc_ssl_server_certificate_config *c_cert_config = NULL - c_cert_config = grpc_ssl_server_certificate_config_create( - c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs, - credentials.c_ssl_pem_key_cert_pairs_count) - cdef grpc_ssl_server_credentials_options* c_options = NULL - # C-core assumes ownership of c_cert_config - c_options = grpc_ssl_server_credentials_create_options_using_config( - GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY - if force_client_auth else - GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, - c_cert_config) - # C-core assumes ownership of c_options - credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options) + credentials.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs) + cdef grpc_ssl_server_certificate_config *c_cert_config = NULL + c_cert_config = grpc_ssl_server_certificate_config_create( + c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs, + credentials.c_ssl_pem_key_cert_pairs_count) + cdef grpc_ssl_server_credentials_options* c_options = NULL + # C-core assumes ownership of c_cert_config + c_options = grpc_ssl_server_credentials_create_options_using_config( + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + if force_client_auth else + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + c_cert_config) + # C-core assumes ownership of c_options + credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options) return credentials -def server_certificate_config_ssl(pem_root_certs, pem_key_cert_pairs): - pem_root_certs = str_to_bytes(pem_root_certs) - pem_key_cert_pairs = list(pem_key_cert_pairs) - cdef ServerCertificateConfig cert_config = ServerCertificateConfig() - cert_config.references.append(pem_root_certs) - cert_config.references.append(pem_key_cert_pairs) - cert_config.c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs) - cert_config.c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs) - cert_config.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs) - cert_config.c_cert_config = grpc_ssl_server_certificate_config_create( - cert_config.c_pem_root_certs, cert_config.c_ssl_pem_key_cert_pairs, - cert_config.c_ssl_pem_key_cert_pairs_count) - return cert_config - -def server_credentials_ssl_dynamic_cert_config(initial_cert_config, - cert_config_fetcher, - bint force_client_auth): - if not isinstance(initial_cert_config, grpc.ServerCertificateConfiguration): - raise TypeError( - 'initial_cert_config must be a grpc.ServerCertificateConfiguration') - if not callable(cert_config_fetcher): - raise TypeError('cert_config_fetcher must be callable') - cdef ServerCredentials credentials = ServerCredentials() - credentials.initial_cert_config = initial_cert_config - credentials.cert_config_fetcher = cert_config_fetcher - cdef grpc_ssl_server_credentials_options* c_options = NULL - c_options = grpc_ssl_server_credentials_create_options_using_config_fetcher( - GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY - if force_client_auth else - GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, - _server_cert_config_fetcher_wrapper, - <void*>credentials) - # C-core assumes ownership of c_options - credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options) - return credentials +def server_certificate_config_ssl(pem_root_certs, pem_key_cert_pairs): + pem_root_certs = str_to_bytes(pem_root_certs) + pem_key_cert_pairs = list(pem_key_cert_pairs) + cdef ServerCertificateConfig cert_config = ServerCertificateConfig() + cert_config.references.append(pem_root_certs) + cert_config.references.append(pem_key_cert_pairs) + cert_config.c_pem_root_certs = _get_c_pem_root_certs(pem_root_certs) + cert_config.c_ssl_pem_key_cert_pairs_count = len(pem_key_cert_pairs) + cert_config.c_ssl_pem_key_cert_pairs = _create_c_ssl_pem_key_cert_pairs(pem_key_cert_pairs) + cert_config.c_cert_config = grpc_ssl_server_certificate_config_create( + cert_config.c_pem_root_certs, cert_config.c_ssl_pem_key_cert_pairs, + cert_config.c_ssl_pem_key_cert_pairs_count) + return cert_config + +def server_credentials_ssl_dynamic_cert_config(initial_cert_config, + cert_config_fetcher, + bint force_client_auth): + if not isinstance(initial_cert_config, grpc.ServerCertificateConfiguration): + raise TypeError( + 'initial_cert_config must be a grpc.ServerCertificateConfiguration') + if not callable(cert_config_fetcher): + raise TypeError('cert_config_fetcher must be callable') + cdef ServerCredentials credentials = ServerCredentials() + credentials.initial_cert_config = initial_cert_config + credentials.cert_config_fetcher = cert_config_fetcher + cdef grpc_ssl_server_credentials_options* c_options = NULL + c_options = grpc_ssl_server_credentials_create_options_using_config_fetcher( + GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY + if force_client_auth else + GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, + _server_cert_config_fetcher_wrapper, + <void*>credentials) + # C-core assumes ownership of c_options + credentials.c_credentials = grpc_ssl_server_credentials_create_with_options(c_options) + return credentials cdef grpc_ssl_certificate_config_reload_status _server_cert_config_fetcher_wrapper( void* user_data, grpc_ssl_server_certificate_config **config) with gil: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi index 686199ecf4..664762380f 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pxd.pxi @@ -1,45 +1,45 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class ConnectivityEvent: - - cdef readonly grpc_completion_type completion_type - cdef readonly bint success - cdef readonly object tag - - -cdef class RequestCallEvent: - - cdef readonly grpc_completion_type completion_type - cdef readonly bint success - cdef readonly object tag - cdef readonly Call call - cdef readonly CallDetails call_details - cdef readonly tuple invocation_metadata - - -cdef class BatchOperationEvent: - - cdef readonly grpc_completion_type completion_type - cdef readonly bint success - cdef readonly object tag - cdef readonly object batch_operations - - -cdef class ServerShutdownEvent: - - cdef readonly grpc_completion_type completion_type - cdef readonly bint success - cdef readonly object tag +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class ConnectivityEvent: + + cdef readonly grpc_completion_type completion_type + cdef readonly bint success + cdef readonly object tag + + +cdef class RequestCallEvent: + + cdef readonly grpc_completion_type completion_type + cdef readonly bint success + cdef readonly object tag + cdef readonly Call call + cdef readonly CallDetails call_details + cdef readonly tuple invocation_metadata + + +cdef class BatchOperationEvent: + + cdef readonly grpc_completion_type completion_type + cdef readonly bint success + cdef readonly object tag + cdef readonly object batch_operations + + +cdef class ServerShutdownEvent: + + cdef readonly grpc_completion_type completion_type + cdef readonly bint success + cdef readonly object tag diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi index af26d27318..64437d9614 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/event.pyx.pxi @@ -1,55 +1,55 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class ConnectivityEvent: - - def __cinit__( - self, grpc_completion_type completion_type, bint success, object tag): - self.completion_type = completion_type - self.success = success - self.tag = tag - - -cdef class RequestCallEvent: - - def __cinit__( - self, grpc_completion_type completion_type, bint success, object tag, - Call call, CallDetails call_details, tuple invocation_metadata): - self.completion_type = completion_type - self.success = success - self.tag = tag - self.call = call - self.call_details = call_details - self.invocation_metadata = invocation_metadata - - -cdef class BatchOperationEvent: - - def __cinit__( - self, grpc_completion_type completion_type, bint success, object tag, - object batch_operations): - self.completion_type = completion_type - self.success = success - self.tag = tag - self.batch_operations = batch_operations - - -cdef class ServerShutdownEvent: - - def __cinit__( - self, grpc_completion_type completion_type, bint success, object tag): - self.completion_type = completion_type - self.success = success - self.tag = tag +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class ConnectivityEvent: + + def __cinit__( + self, grpc_completion_type completion_type, bint success, object tag): + self.completion_type = completion_type + self.success = success + self.tag = tag + + +cdef class RequestCallEvent: + + def __cinit__( + self, grpc_completion_type completion_type, bint success, object tag, + Call call, CallDetails call_details, tuple invocation_metadata): + self.completion_type = completion_type + self.success = success + self.tag = tag + self.call = call + self.call_details = call_details + self.invocation_metadata = invocation_metadata + + +cdef class BatchOperationEvent: + + def __cinit__( + self, grpc_completion_type completion_type, bint success, object tag, + object batch_operations): + self.completion_type = completion_type + self.success = success + self.tag = tag + self.batch_operations = batch_operations + + +cdef class ServerShutdownEvent: + + def __cinit__( + self, grpc_completion_type completion_type, bint success, object tag): + self.completion_type = completion_type + self.success = success + self.tag = tag diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 54eb7fdffc..bc34b061f8 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cimport libc.time @@ -29,7 +29,7 @@ ctypedef unsigned long long uint64_t cdef extern from "grpc/support/alloc.h": void *gpr_malloc(size_t size) nogil - void *gpr_zalloc(size_t size) nogil + void *gpr_zalloc(size_t size) nogil void gpr_free(void *ptr) nogil void *gpr_realloc(void *p, size_t size) nogil @@ -55,14 +55,14 @@ cdef extern from "grpc/grpc.h": grpc_slice grpc_slice_ref(grpc_slice s) nogil void grpc_slice_unref(grpc_slice s) nogil - grpc_slice grpc_empty_slice() nogil + grpc_slice grpc_empty_slice() nogil grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) nogil grpc_slice grpc_slice_new_with_len( void *p, size_t len, void (*destroy)(void *, size_t)) nogil grpc_slice grpc_slice_malloc(size_t length) nogil grpc_slice grpc_slice_from_copied_string(const char *source) nogil grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len) nogil - grpc_slice grpc_slice_copy(grpc_slice s) nogil + grpc_slice grpc_slice_copy(grpc_slice s) nogil # Declare functions for function-like macros (because Cython)... void *grpc_slice_start_ptr "GRPC_SLICE_START_PTR" (grpc_slice s) nogil @@ -183,7 +183,7 @@ cdef extern from "grpc/grpc.h": ctypedef struct grpc_arg_pointer_vtable: void *(*copy)(void *) - void (*destroy)(void *) + void (*destroy)(void *) int (*cmp)(void *, void *) ctypedef struct grpc_arg_value_pointer: @@ -204,12 +204,12 @@ cdef extern from "grpc/grpc.h": size_t arguments_length "num_args" grpc_arg *arguments "args" - ctypedef enum grpc_stream_compression_level: - GRPC_STREAM_COMPRESS_LEVEL_NONE - GRPC_STREAM_COMPRESS_LEVEL_LOW - GRPC_STREAM_COMPRESS_LEVEL_MED - GRPC_STREAM_COMPRESS_LEVEL_HIGH - + ctypedef enum grpc_stream_compression_level: + GRPC_STREAM_COMPRESS_LEVEL_NONE + GRPC_STREAM_COMPRESS_LEVEL_LOW + GRPC_STREAM_COMPRESS_LEVEL_MED + GRPC_STREAM_COMPRESS_LEVEL_HIGH + ctypedef enum grpc_call_error: GRPC_CALL_OK GRPC_CALL_ERROR @@ -223,20 +223,20 @@ cdef extern from "grpc/grpc.h": GRPC_CALL_ERROR_INVALID_FLAGS GRPC_CALL_ERROR_INVALID_METADATA - ctypedef enum grpc_cq_completion_type: - GRPC_CQ_NEXT - GRPC_CQ_PLUCK - - ctypedef enum grpc_cq_polling_type: - GRPC_CQ_DEFAULT_POLLING - GRPC_CQ_NON_LISTENING - GRPC_CQ_NON_POLLING - - ctypedef struct grpc_completion_queue_attributes: - int version - grpc_cq_completion_type cq_completion_type - grpc_cq_polling_type cq_polling_type - + ctypedef enum grpc_cq_completion_type: + GRPC_CQ_NEXT + GRPC_CQ_PLUCK + + ctypedef enum grpc_cq_polling_type: + GRPC_CQ_DEFAULT_POLLING + GRPC_CQ_NON_LISTENING + GRPC_CQ_NON_POLLING + + ctypedef struct grpc_completion_queue_attributes: + int version + grpc_cq_completion_type cq_completion_type + grpc_cq_polling_type cq_polling_type + ctypedef enum grpc_connectivity_state: GRPC_CHANNEL_IDLE GRPC_CHANNEL_CONNECTING @@ -245,8 +245,8 @@ cdef extern from "grpc/grpc.h": GRPC_CHANNEL_SHUTDOWN ctypedef struct grpc_metadata: - grpc_slice key - grpc_slice value + grpc_slice key + grpc_slice value # ignore the 'internal_data.obfuscated' fields. ctypedef enum grpc_completion_type: @@ -268,8 +268,8 @@ cdef extern from "grpc/grpc.h": void grpc_metadata_array_destroy(grpc_metadata_array *array) nogil ctypedef struct grpc_call_details: - grpc_slice method - grpc_slice host + grpc_slice method + grpc_slice host gpr_timespec deadline void grpc_call_details_init(grpc_call_details *details) nogil @@ -285,25 +285,25 @@ cdef extern from "grpc/grpc.h": GRPC_OP_RECV_STATUS_ON_CLIENT GRPC_OP_RECV_CLOSE_ON_SERVER - ctypedef struct grpc_op_send_initial_metadata_maybe_compression_level: - uint8_t is_set - grpc_compression_level level - + ctypedef struct grpc_op_send_initial_metadata_maybe_compression_level: + uint8_t is_set + grpc_compression_level level + ctypedef struct grpc_op_data_send_initial_metadata: size_t count grpc_metadata *metadata - grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level + grpc_op_send_initial_metadata_maybe_compression_level maybe_compression_level ctypedef struct grpc_op_data_send_status_from_server: size_t trailing_metadata_count grpc_metadata *trailing_metadata grpc_status_code status - grpc_slice *status_details + grpc_slice *status_details ctypedef struct grpc_op_data_recv_status_on_client: grpc_metadata_array *trailing_metadata grpc_status_code *status - grpc_slice *status_details + grpc_slice *status_details char** error_string ctypedef struct grpc_op_data_recv_close_on_server: @@ -338,16 +338,16 @@ cdef extern from "grpc/grpc.h": void grpc_shutdown_blocking() nogil int grpc_is_initialized() nogil - ctypedef struct grpc_completion_queue_factory: - pass - - grpc_completion_queue_factory *grpc_completion_queue_factory_lookup( - const grpc_completion_queue_attributes* attributes) nogil - grpc_completion_queue *grpc_completion_queue_create( - const grpc_completion_queue_factory* factory, - const grpc_completion_queue_attributes* attr, void* reserved) nogil - grpc_completion_queue *grpc_completion_queue_create_for_next(void *reserved) nogil - + ctypedef struct grpc_completion_queue_factory: + pass + + grpc_completion_queue_factory *grpc_completion_queue_factory_lookup( + const grpc_completion_queue_attributes* attributes) nogil + grpc_completion_queue *grpc_completion_queue_create( + const grpc_completion_queue_factory* factory, + const grpc_completion_queue_attributes* attr, void* reserved) nogil + grpc_completion_queue *grpc_completion_queue_create_for_next(void *reserved) nogil + grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved) nogil @@ -370,15 +370,15 @@ cdef extern from "grpc/grpc.h": const char *description, void *reserved) nogil char *grpc_call_get_peer(grpc_call *call) nogil - void grpc_call_unref(grpc_call *call) nogil + void grpc_call_unref(grpc_call *call) nogil grpc_channel *grpc_insecure_channel_create(const char *target, const grpc_channel_args *args, void *reserved) nogil grpc_call *grpc_channel_create_call( - grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, - grpc_completion_queue *completion_queue, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved) nogil + grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, + grpc_completion_queue *completion_queue, grpc_slice method, + const grpc_slice *host, gpr_timespec deadline, void *reserved) nogil grpc_connectivity_state grpc_channel_check_connectivity_state( grpc_channel *channel, int try_to_connect) nogil void grpc_channel_watch_connectivity_state( @@ -418,10 +418,10 @@ cdef extern from "grpc/grpc.h": cdef extern from "grpc/grpc_security.h": - # Declare this as an enum, this is the only way to make it a const in - # cython - enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX - + # Declare this as an enum, this is the only way to make it a const in + # cython + enum: GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX + ctypedef enum grpc_ssl_roots_override_result: GRPC_SSL_ROOTS_OVERRIDE_OK GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY @@ -441,42 +441,42 @@ cdef extern from "grpc/grpc_security.h": GRPC_PRIVACY_AND_INTEGRITY GRPC_SECURITY_MAX = GRPC_PRIVACY_AND_INTEGRITY - ctypedef enum grpc_ssl_certificate_config_reload_status: - GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED - GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW - GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL - - ctypedef struct grpc_ssl_server_certificate_config: - # We don't care about the internals - pass - - ctypedef struct grpc_ssl_server_credentials_options: - # We don't care about the internals - pass - - grpc_ssl_server_certificate_config * grpc_ssl_server_certificate_config_create( - const char *pem_root_certs, - const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, - size_t num_key_cert_pairs) - - void grpc_ssl_server_certificate_config_destroy(grpc_ssl_server_certificate_config *config) - - ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)( - void *user_data, - grpc_ssl_server_certificate_config **config) - - grpc_ssl_server_credentials_options *grpc_ssl_server_credentials_create_options_using_config( - grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config *certificate_config) - - grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config_fetcher( - grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config_callback cb, - void *user_data) - - grpc_server_credentials *grpc_ssl_server_credentials_create_with_options( - grpc_ssl_server_credentials_options *options) - + ctypedef enum grpc_ssl_certificate_config_reload_status: + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_UNCHANGED + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_NEW + GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL + + ctypedef struct grpc_ssl_server_certificate_config: + # We don't care about the internals + pass + + ctypedef struct grpc_ssl_server_credentials_options: + # We don't care about the internals + pass + + grpc_ssl_server_certificate_config * grpc_ssl_server_certificate_config_create( + const char *pem_root_certs, + const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, + size_t num_key_cert_pairs) + + void grpc_ssl_server_certificate_config_destroy(grpc_ssl_server_certificate_config *config) + + ctypedef grpc_ssl_certificate_config_reload_status (*grpc_ssl_server_certificate_config_callback)( + void *user_data, + grpc_ssl_server_certificate_config **config) + + grpc_ssl_server_credentials_options *grpc_ssl_server_credentials_create_options_using_config( + grpc_ssl_client_certificate_request_type client_certificate_request, + grpc_ssl_server_certificate_config *certificate_config) + + grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config_fetcher( + grpc_ssl_client_certificate_request_type client_certificate_request, + grpc_ssl_server_certificate_config_callback cb, + void *user_data) + + grpc_server_credentials *grpc_ssl_server_credentials_create_with_options( + grpc_ssl_server_credentials_options *options) + ctypedef struct grpc_ssl_pem_key_cert_pair: const char *private_key const char *certificate_chain "cert_chain" @@ -559,11 +559,11 @@ cdef extern from "grpc/grpc_security.h": grpc_status_code status, const char *error_details) ctypedef struct grpc_metadata_credentials_plugin: - int (*get_metadata)( + int (*get_metadata)( void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, - grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, + grpc_credentials_plugin_metadata_cb cb, void *user_data, + grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], + size_t *num_creds_md, grpc_status_code *status, const char **error_details) except * void (*destroy)(void *state) except * void *state @@ -572,36 +572,36 @@ cdef extern from "grpc/grpc_security.h": grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( grpc_metadata_credentials_plugin plugin, grpc_security_level min_security_level, void *reserved) nogil - ctypedef struct grpc_auth_property_iterator: - pass - - ctypedef struct grpc_auth_property: - char *name - char *value - size_t value_length - - grpc_auth_property *grpc_auth_property_iterator_next( - grpc_auth_property_iterator *it) - - grpc_auth_property_iterator grpc_auth_context_property_iterator( - const grpc_auth_context *ctx) - - grpc_auth_property_iterator grpc_auth_context_peer_identity( - const grpc_auth_context *ctx) - - char *grpc_auth_context_peer_identity_property_name( - const grpc_auth_context *ctx) - - grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( - const grpc_auth_context *ctx, const char *name) - - grpc_auth_context_peer_is_authenticated( - const grpc_auth_context *ctx) - - grpc_auth_context *grpc_call_auth_context(grpc_call *call) - - void grpc_auth_context_release(grpc_auth_context *context) + ctypedef struct grpc_auth_property_iterator: + pass + ctypedef struct grpc_auth_property: + char *name + char *value + size_t value_length + + grpc_auth_property *grpc_auth_property_iterator_next( + grpc_auth_property_iterator *it) + + grpc_auth_property_iterator grpc_auth_context_property_iterator( + const grpc_auth_context *ctx) + + grpc_auth_property_iterator grpc_auth_context_peer_identity( + const grpc_auth_context *ctx) + + char *grpc_auth_context_peer_identity_property_name( + const grpc_auth_context *ctx) + + grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( + const grpc_auth_context *ctx, const char *name) + + grpc_auth_context_peer_is_authenticated( + const grpc_auth_context *ctx) + + grpc_auth_context *grpc_call_auth_context(grpc_call *call) + + void grpc_auth_context_release(grpc_auth_context *context) + grpc_channel_credentials *grpc_local_credentials_create( grpc_local_connect_type type) grpc_server_credentials *grpc_local_server_credentials_create( @@ -629,7 +629,7 @@ cdef extern from "grpc/compression.h": GRPC_COMPRESS_NONE GRPC_COMPRESS_DEFLATE GRPC_COMPRESS_GZIP - GRPC_COMPRESS_STREAM_GZIP + GRPC_COMPRESS_STREAM_GZIP GRPC_COMPRESS_ALGORITHMS_COUNT ctypedef enum grpc_compression_level: @@ -643,9 +643,9 @@ cdef extern from "grpc/compression.h": uint32_t enabled_algorithms_bitset int grpc_compression_algorithm_parse( - grpc_slice value, grpc_compression_algorithm *algorithm) nogil + grpc_slice value, grpc_compression_algorithm *algorithm) nogil int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm, - const char **name) nogil + const char **name) nogil grpc_compression_algorithm grpc_compression_algorithm_for_level( grpc_compression_level level, uint32_t accepted_encodings) nogil void grpc_compression_options_init(grpc_compression_options *opts) nogil diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi index 5c1e0679a9..ac8e3d01c1 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/grpc_string.pyx.pxi @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # This function will ascii encode unicode string inputs if necessary. @@ -22,30 +22,30 @@ cdef bytes str_to_bytes(object s): return s.encode('ascii') else: raise TypeError('Expected bytes, str, or unicode, not {}'.format(type(s))) - - -# TODO(https://github.com/grpc/grpc/issues/13782): It would be nice for us if -# the type of metadata that we accept were exactly the same as the type of -# metadata that we deliver to our users (so "str" for this function's -# parameter rather than "object"), but would it be nice for our users? Right -# now we haven't yet heard from enough users to know one way or another. -cdef bytes _encode(object string_or_none): - if string_or_none is None: - return b'' - elif isinstance(string_or_none, (bytes,)): - return <bytes>string_or_none - elif isinstance(string_or_none, (unicode,)): + + +# TODO(https://github.com/grpc/grpc/issues/13782): It would be nice for us if +# the type of metadata that we accept were exactly the same as the type of +# metadata that we deliver to our users (so "str" for this function's +# parameter rather than "object"), but would it be nice for our users? Right +# now we haven't yet heard from enough users to know one way or another. +cdef bytes _encode(object string_or_none): + if string_or_none is None: + return b'' + elif isinstance(string_or_none, (bytes,)): + return <bytes>string_or_none + elif isinstance(string_or_none, (unicode,)): return string_or_none.encode('utf8') - else: - raise TypeError('Expected str, not {}'.format(type(string_or_none))) - - -cdef str _decode(bytes bytestring): - if isinstance(bytestring, (str,)): - return <str>bytestring - else: - try: - return bytestring.decode('utf8') - except UnicodeDecodeError: + else: + raise TypeError('Expected str, not {}'.format(type(string_or_none))) + + +cdef str _decode(bytes bytestring): + if isinstance(bytestring, (str,)): + return <str>bytestring + else: + try: + return bytestring.decode('utf8') + except UnicodeDecodeError: _LOGGER.exception('Invalid encoding on %s', bytestring) - return bytestring.decode('latin1') + return bytestring.decode('latin1') diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi index fc72ac1576..d743aae561 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pxd.pxi @@ -1,26 +1,26 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef void _store_c_metadata( +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef void _store_c_metadata( metadata, grpc_metadata **c_metadata, size_t *c_count) except * - - + + cdef void _release_c_metadata(grpc_metadata *c_metadata, int count) except * - - -cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice) - - -cdef tuple _metadata(grpc_metadata_array *c_metadata_array) + + +cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice) + + +cdef tuple _metadata(grpc_metadata_array *c_metadata_array) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi index b2dd1e3380..0c52a22489 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/metadata.pyx.pxi @@ -1,73 +1,73 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import collections - - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections + + class InitialMetadataFlags: used_mask = GRPC_INITIAL_METADATA_USED_MASK wait_for_ready = GRPC_INITIAL_METADATA_WAIT_FOR_READY wait_for_ready_explicitly_set = GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET -_Metadatum = collections.namedtuple('_Metadatum', ('key', 'value',)) - - -cdef void _store_c_metadata( +_Metadatum = collections.namedtuple('_Metadatum', ('key', 'value',)) + + +cdef void _store_c_metadata( metadata, grpc_metadata **c_metadata, size_t *c_count) except *: - if metadata is None: - c_count[0] = 0 - c_metadata[0] = NULL - else: - metadatum_count = len(metadata) - if metadatum_count == 0: - c_count[0] = 0 - c_metadata[0] = NULL - else: - c_count[0] = metadatum_count - c_metadata[0] = <grpc_metadata *>gpr_malloc( - metadatum_count * sizeof(grpc_metadata)) - for index, (key, value) in enumerate(metadata): - encoded_key = _encode(key) - encoded_value = value if encoded_key[-4:] == b'-bin' else _encode(value) + if metadata is None: + c_count[0] = 0 + c_metadata[0] = NULL + else: + metadatum_count = len(metadata) + if metadatum_count == 0: + c_count[0] = 0 + c_metadata[0] = NULL + else: + c_count[0] = metadatum_count + c_metadata[0] = <grpc_metadata *>gpr_malloc( + metadatum_count * sizeof(grpc_metadata)) + for index, (key, value) in enumerate(metadata): + encoded_key = _encode(key) + encoded_value = value if encoded_key[-4:] == b'-bin' else _encode(value) if not isinstance(encoded_value, bytes): raise TypeError('Binary metadata key="%s" expected bytes, got %s' % ( key, type(encoded_value) )) - c_metadata[0][index].key = _slice_from_bytes(encoded_key) - c_metadata[0][index].value = _slice_from_bytes(encoded_value) - - + c_metadata[0][index].key = _slice_from_bytes(encoded_key) + c_metadata[0][index].value = _slice_from_bytes(encoded_value) + + cdef void _release_c_metadata(grpc_metadata *c_metadata, int count) except *: - if 0 < count: - for index in range(count): - grpc_slice_unref(c_metadata[index].key) - grpc_slice_unref(c_metadata[index].value) - gpr_free(c_metadata) - - -cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice): - cdef bytes key = _slice_bytes(key_slice) - cdef bytes value = _slice_bytes(value_slice) - return <tuple>_Metadatum( - _decode(key), value if key[-4:] == b'-bin' else _decode(value)) - - -cdef tuple _metadata(grpc_metadata_array *c_metadata_array): - return tuple( - _metadatum( - c_metadata_array.metadata[index].key, - c_metadata_array.metadata[index].value) - for index in range(c_metadata_array.count)) + if 0 < count: + for index in range(count): + grpc_slice_unref(c_metadata[index].key) + grpc_slice_unref(c_metadata[index].value) + gpr_free(c_metadata) + + +cdef tuple _metadatum(grpc_slice key_slice, grpc_slice value_slice): + cdef bytes key = _slice_bytes(key_slice) + cdef bytes value = _slice_bytes(value_slice) + return <tuple>_Metadatum( + _decode(key), value if key[-4:] == b'-bin' else _decode(value)) + + +cdef tuple _metadata(grpc_metadata_array *c_metadata_array): + return tuple( + _metadatum( + c_metadata_array.metadata[index].key, + c_metadata_array.metadata[index].value) + for index in range(c_metadata_array.count)) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi index c9df32dadf..a992eca09c 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pxd.pxi @@ -1,111 +1,111 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class Operation: - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class Operation: + cdef void c(self) except * cdef void un_c(self) except * - - # TODO(https://github.com/grpc/grpc/issues/7950): Eliminate this! - cdef grpc_op c_op - - -cdef class SendInitialMetadataOperation(Operation): - - cdef readonly object _initial_metadata; - cdef readonly int _flags - cdef grpc_metadata *_c_initial_metadata - cdef size_t _c_initial_metadata_count - + + # TODO(https://github.com/grpc/grpc/issues/7950): Eliminate this! + cdef grpc_op c_op + + +cdef class SendInitialMetadataOperation(Operation): + + cdef readonly object _initial_metadata; + cdef readonly int _flags + cdef grpc_metadata *_c_initial_metadata + cdef size_t _c_initial_metadata_count + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class SendMessageOperation(Operation): - - cdef readonly bytes _message - cdef readonly int _flags - cdef grpc_byte_buffer *_c_message_byte_buffer - + + +cdef class SendMessageOperation(Operation): + + cdef readonly bytes _message + cdef readonly int _flags + cdef grpc_byte_buffer *_c_message_byte_buffer + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class SendCloseFromClientOperation(Operation): - - cdef readonly int _flags - + + +cdef class SendCloseFromClientOperation(Operation): + + cdef readonly int _flags + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class SendStatusFromServerOperation(Operation): - - cdef readonly object _trailing_metadata - cdef readonly object _code - cdef readonly object _details - cdef readonly int _flags - cdef grpc_metadata *_c_trailing_metadata - cdef size_t _c_trailing_metadata_count - cdef grpc_slice _c_details - + + +cdef class SendStatusFromServerOperation(Operation): + + cdef readonly object _trailing_metadata + cdef readonly object _code + cdef readonly object _details + cdef readonly int _flags + cdef grpc_metadata *_c_trailing_metadata + cdef size_t _c_trailing_metadata_count + cdef grpc_slice _c_details + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class ReceiveInitialMetadataOperation(Operation): - - cdef readonly int _flags - cdef tuple _initial_metadata - cdef grpc_metadata_array _c_initial_metadata - + + +cdef class ReceiveInitialMetadataOperation(Operation): + + cdef readonly int _flags + cdef tuple _initial_metadata + cdef grpc_metadata_array _c_initial_metadata + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class ReceiveMessageOperation(Operation): - - cdef readonly int _flags - cdef grpc_byte_buffer *_c_message_byte_buffer - cdef bytes _message - + + +cdef class ReceiveMessageOperation(Operation): + + cdef readonly int _flags + cdef grpc_byte_buffer *_c_message_byte_buffer + cdef bytes _message + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class ReceiveStatusOnClientOperation(Operation): - - cdef readonly int _flags - cdef grpc_metadata_array _c_trailing_metadata - cdef grpc_status_code _c_code - cdef grpc_slice _c_details + + +cdef class ReceiveStatusOnClientOperation(Operation): + + cdef readonly int _flags + cdef grpc_metadata_array _c_trailing_metadata + cdef grpc_status_code _c_code + cdef grpc_slice _c_details cdef const char* _c_error_string - cdef tuple _trailing_metadata - cdef object _code - cdef str _details + cdef tuple _trailing_metadata + cdef object _code + cdef str _details cdef str _error_string - + cdef void c(self) except * cdef void un_c(self) except * - - -cdef class ReceiveCloseOnServerOperation(Operation): - - cdef readonly int _flags - cdef object _cancelled - cdef int _c_cancelled - + + +cdef class ReceiveCloseOnServerOperation(Operation): + + cdef readonly int _flags + cdef object _cancelled + cdef int _c_cancelled + cdef void c(self) except * cdef void un_c(self) except * diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi index 3f3fd75407..a1e1b61665 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi @@ -1,250 +1,250 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class Operation: - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class Operation: + cdef void c(self) except *: - raise NotImplementedError() - + raise NotImplementedError() + cdef void un_c(self) except *: - raise NotImplementedError() - - -cdef class SendInitialMetadataOperation(Operation): - - def __cinit__(self, initial_metadata, flags): - self._initial_metadata = initial_metadata - self._flags = flags - - def type(self): - return GRPC_OP_SEND_INITIAL_METADATA - + raise NotImplementedError() + + +cdef class SendInitialMetadataOperation(Operation): + + def __cinit__(self, initial_metadata, flags): + self._initial_metadata = initial_metadata + self._flags = flags + + def type(self): + return GRPC_OP_SEND_INITIAL_METADATA + cdef void c(self) except *: - self.c_op.type = GRPC_OP_SEND_INITIAL_METADATA - self.c_op.flags = self._flags - _store_c_metadata( - self._initial_metadata, &self._c_initial_metadata, - &self._c_initial_metadata_count) - self.c_op.data.send_initial_metadata.metadata = self._c_initial_metadata - self.c_op.data.send_initial_metadata.count = self._c_initial_metadata_count - self.c_op.data.send_initial_metadata.maybe_compression_level.is_set = 0 - + self.c_op.type = GRPC_OP_SEND_INITIAL_METADATA + self.c_op.flags = self._flags + _store_c_metadata( + self._initial_metadata, &self._c_initial_metadata, + &self._c_initial_metadata_count) + self.c_op.data.send_initial_metadata.metadata = self._c_initial_metadata + self.c_op.data.send_initial_metadata.count = self._c_initial_metadata_count + self.c_op.data.send_initial_metadata.maybe_compression_level.is_set = 0 + cdef void un_c(self) except *: - _release_c_metadata( - self._c_initial_metadata, self._c_initial_metadata_count) - - -cdef class SendMessageOperation(Operation): - - def __cinit__(self, bytes message, int flags): + _release_c_metadata( + self._c_initial_metadata, self._c_initial_metadata_count) + + +cdef class SendMessageOperation(Operation): + + def __cinit__(self, bytes message, int flags): if message is None: self._message = b'' else: self._message = message - self._flags = flags - - def type(self): - return GRPC_OP_SEND_MESSAGE - + self._flags = flags + + def type(self): + return GRPC_OP_SEND_MESSAGE + cdef void c(self) except *: - self.c_op.type = GRPC_OP_SEND_MESSAGE - self.c_op.flags = self._flags - cdef grpc_slice message_slice = grpc_slice_from_copied_buffer( - self._message, len(self._message)) - self._c_message_byte_buffer = grpc_raw_byte_buffer_create( - &message_slice, 1) - grpc_slice_unref(message_slice) - self.c_op.data.send_message.send_message = self._c_message_byte_buffer - + self.c_op.type = GRPC_OP_SEND_MESSAGE + self.c_op.flags = self._flags + cdef grpc_slice message_slice = grpc_slice_from_copied_buffer( + self._message, len(self._message)) + self._c_message_byte_buffer = grpc_raw_byte_buffer_create( + &message_slice, 1) + grpc_slice_unref(message_slice) + self.c_op.data.send_message.send_message = self._c_message_byte_buffer + cdef void un_c(self) except *: - grpc_byte_buffer_destroy(self._c_message_byte_buffer) - - -cdef class SendCloseFromClientOperation(Operation): - - def __cinit__(self, int flags): - self._flags = flags - - def type(self): - return GRPC_OP_SEND_CLOSE_FROM_CLIENT - + grpc_byte_buffer_destroy(self._c_message_byte_buffer) + + +cdef class SendCloseFromClientOperation(Operation): + + def __cinit__(self, int flags): + self._flags = flags + + def type(self): + return GRPC_OP_SEND_CLOSE_FROM_CLIENT + cdef void c(self) except *: - self.c_op.type = GRPC_OP_SEND_CLOSE_FROM_CLIENT - self.c_op.flags = self._flags - + self.c_op.type = GRPC_OP_SEND_CLOSE_FROM_CLIENT + self.c_op.flags = self._flags + cdef void un_c(self) except *: - pass - - -cdef class SendStatusFromServerOperation(Operation): - - def __cinit__(self, trailing_metadata, code, object details, int flags): - self._trailing_metadata = trailing_metadata - self._code = code - self._details = details - self._flags = flags - - def type(self): - return GRPC_OP_SEND_STATUS_FROM_SERVER - + pass + + +cdef class SendStatusFromServerOperation(Operation): + + def __cinit__(self, trailing_metadata, code, object details, int flags): + self._trailing_metadata = trailing_metadata + self._code = code + self._details = details + self._flags = flags + + def type(self): + return GRPC_OP_SEND_STATUS_FROM_SERVER + cdef void c(self) except *: - self.c_op.type = GRPC_OP_SEND_STATUS_FROM_SERVER - self.c_op.flags = self._flags - _store_c_metadata( - self._trailing_metadata, &self._c_trailing_metadata, - &self._c_trailing_metadata_count) - self.c_op.data.send_status_from_server.trailing_metadata = ( - self._c_trailing_metadata) - self.c_op.data.send_status_from_server.trailing_metadata_count = ( - self._c_trailing_metadata_count) - self.c_op.data.send_status_from_server.status = self._code - self._c_details = _slice_from_bytes(_encode(self._details)) - self.c_op.data.send_status_from_server.status_details = &self._c_details - + self.c_op.type = GRPC_OP_SEND_STATUS_FROM_SERVER + self.c_op.flags = self._flags + _store_c_metadata( + self._trailing_metadata, &self._c_trailing_metadata, + &self._c_trailing_metadata_count) + self.c_op.data.send_status_from_server.trailing_metadata = ( + self._c_trailing_metadata) + self.c_op.data.send_status_from_server.trailing_metadata_count = ( + self._c_trailing_metadata_count) + self.c_op.data.send_status_from_server.status = self._code + self._c_details = _slice_from_bytes(_encode(self._details)) + self.c_op.data.send_status_from_server.status_details = &self._c_details + cdef void un_c(self) except *: - grpc_slice_unref(self._c_details) - _release_c_metadata( - self._c_trailing_metadata, self._c_trailing_metadata_count) - - -cdef class ReceiveInitialMetadataOperation(Operation): - - def __cinit__(self, flags): - self._flags = flags - - def type(self): - return GRPC_OP_RECV_INITIAL_METADATA - + grpc_slice_unref(self._c_details) + _release_c_metadata( + self._c_trailing_metadata, self._c_trailing_metadata_count) + + +cdef class ReceiveInitialMetadataOperation(Operation): + + def __cinit__(self, flags): + self._flags = flags + + def type(self): + return GRPC_OP_RECV_INITIAL_METADATA + cdef void c(self) except *: - self.c_op.type = GRPC_OP_RECV_INITIAL_METADATA - self.c_op.flags = self._flags - grpc_metadata_array_init(&self._c_initial_metadata) - self.c_op.data.receive_initial_metadata.receive_initial_metadata = ( - &self._c_initial_metadata) - + self.c_op.type = GRPC_OP_RECV_INITIAL_METADATA + self.c_op.flags = self._flags + grpc_metadata_array_init(&self._c_initial_metadata) + self.c_op.data.receive_initial_metadata.receive_initial_metadata = ( + &self._c_initial_metadata) + cdef void un_c(self) except *: - self._initial_metadata = _metadata(&self._c_initial_metadata) - grpc_metadata_array_destroy(&self._c_initial_metadata) - - def initial_metadata(self): - return self._initial_metadata - - -cdef class ReceiveMessageOperation(Operation): - - def __cinit__(self, flags): - self._flags = flags - - def type(self): - return GRPC_OP_RECV_MESSAGE - + self._initial_metadata = _metadata(&self._c_initial_metadata) + grpc_metadata_array_destroy(&self._c_initial_metadata) + + def initial_metadata(self): + return self._initial_metadata + + +cdef class ReceiveMessageOperation(Operation): + + def __cinit__(self, flags): + self._flags = flags + + def type(self): + return GRPC_OP_RECV_MESSAGE + cdef void c(self) except *: - self.c_op.type = GRPC_OP_RECV_MESSAGE - self.c_op.flags = self._flags - self.c_op.data.receive_message.receive_message = ( - &self._c_message_byte_buffer) - + self.c_op.type = GRPC_OP_RECV_MESSAGE + self.c_op.flags = self._flags + self.c_op.data.receive_message.receive_message = ( + &self._c_message_byte_buffer) + cdef void un_c(self) except *: - cdef grpc_byte_buffer_reader message_reader - cdef bint message_reader_status - cdef grpc_slice message_slice - cdef size_t message_slice_length - cdef void *message_slice_pointer - if self._c_message_byte_buffer != NULL: - message_reader_status = grpc_byte_buffer_reader_init( - &message_reader, self._c_message_byte_buffer) - if message_reader_status: - message = bytearray() - while grpc_byte_buffer_reader_next(&message_reader, &message_slice): - message_slice_pointer = grpc_slice_start_ptr(message_slice) - message_slice_length = grpc_slice_length(message_slice) - message += (<char *>message_slice_pointer)[:message_slice_length] - grpc_slice_unref(message_slice) - grpc_byte_buffer_reader_destroy(&message_reader) - self._message = bytes(message) - else: - self._message = None - grpc_byte_buffer_destroy(self._c_message_byte_buffer) - else: - self._message = None - - def message(self): - return self._message - - -cdef class ReceiveStatusOnClientOperation(Operation): - - def __cinit__(self, flags): - self._flags = flags - - def type(self): - return GRPC_OP_RECV_STATUS_ON_CLIENT - + cdef grpc_byte_buffer_reader message_reader + cdef bint message_reader_status + cdef grpc_slice message_slice + cdef size_t message_slice_length + cdef void *message_slice_pointer + if self._c_message_byte_buffer != NULL: + message_reader_status = grpc_byte_buffer_reader_init( + &message_reader, self._c_message_byte_buffer) + if message_reader_status: + message = bytearray() + while grpc_byte_buffer_reader_next(&message_reader, &message_slice): + message_slice_pointer = grpc_slice_start_ptr(message_slice) + message_slice_length = grpc_slice_length(message_slice) + message += (<char *>message_slice_pointer)[:message_slice_length] + grpc_slice_unref(message_slice) + grpc_byte_buffer_reader_destroy(&message_reader) + self._message = bytes(message) + else: + self._message = None + grpc_byte_buffer_destroy(self._c_message_byte_buffer) + else: + self._message = None + + def message(self): + return self._message + + +cdef class ReceiveStatusOnClientOperation(Operation): + + def __cinit__(self, flags): + self._flags = flags + + def type(self): + return GRPC_OP_RECV_STATUS_ON_CLIENT + cdef void c(self) except *: - self.c_op.type = GRPC_OP_RECV_STATUS_ON_CLIENT - self.c_op.flags = self._flags - grpc_metadata_array_init(&self._c_trailing_metadata) - self.c_op.data.receive_status_on_client.trailing_metadata = ( - &self._c_trailing_metadata) - self.c_op.data.receive_status_on_client.status = ( - &self._c_code) - self.c_op.data.receive_status_on_client.status_details = ( - &self._c_details) + self.c_op.type = GRPC_OP_RECV_STATUS_ON_CLIENT + self.c_op.flags = self._flags + grpc_metadata_array_init(&self._c_trailing_metadata) + self.c_op.data.receive_status_on_client.trailing_metadata = ( + &self._c_trailing_metadata) + self.c_op.data.receive_status_on_client.status = ( + &self._c_code) + self.c_op.data.receive_status_on_client.status_details = ( + &self._c_details) self.c_op.data.receive_status_on_client.error_string = ( &self._c_error_string) - + cdef void un_c(self) except *: - self._trailing_metadata = _metadata(&self._c_trailing_metadata) - grpc_metadata_array_destroy(&self._c_trailing_metadata) - self._code = self._c_code - self._details = _decode(_slice_bytes(self._c_details)) - grpc_slice_unref(self._c_details) + self._trailing_metadata = _metadata(&self._c_trailing_metadata) + grpc_metadata_array_destroy(&self._c_trailing_metadata) + self._code = self._c_code + self._details = _decode(_slice_bytes(self._c_details)) + grpc_slice_unref(self._c_details) if self._c_error_string != NULL: self._error_string = _decode(self._c_error_string) gpr_free(<void*>self._c_error_string) else: self._error_string = "" - - def trailing_metadata(self): - return self._trailing_metadata - - def code(self): - return self._code - - def details(self): - return self._details - + + def trailing_metadata(self): + return self._trailing_metadata + + def code(self): + return self._code + + def details(self): + return self._details + def error_string(self): return self._error_string - - -cdef class ReceiveCloseOnServerOperation(Operation): - - def __cinit__(self, flags): - self._flags = flags - - def type(self): - return GRPC_OP_RECV_CLOSE_ON_SERVER - + + +cdef class ReceiveCloseOnServerOperation(Operation): + + def __cinit__(self, flags): + self._flags = flags + + def type(self): + return GRPC_OP_RECV_CLOSE_ON_SERVER + cdef void c(self) except *: - self.c_op.type = GRPC_OP_RECV_CLOSE_ON_SERVER - self.c_op.flags = self._flags - self.c_op.data.receive_close_on_server.cancelled = &self._c_cancelled - + self.c_op.type = GRPC_OP_RECV_CLOSE_ON_SERVER + self.c_op.flags = self._flags + self.c_op.data.receive_close_on_server.cancelled = &self._c_cancelled + cdef void un_c(self) except *: - self._cancelled = bool(self._c_cancelled) - - def cancelled(self): - return self._cancelled + self._cancelled = bool(self._c_cancelled) + + def cancelled(self): + return self._cancelled diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi index 35e1bdb0ae..d69b51a9e8 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pxd.pxi @@ -1,21 +1,21 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -cdef bytes _slice_bytes(grpc_slice slice) -cdef grpc_slice _copy_slice(grpc_slice slice) nogil -cdef grpc_slice _slice_from_bytes(bytes value) nogil +cdef bytes _slice_bytes(grpc_slice slice) +cdef grpc_slice _copy_slice(grpc_slice slice) nogil +cdef grpc_slice _slice_from_bytes(bytes value) nogil cdef class CallDetails: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 308d677695..755bc9fa9d 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -1,37 +1,37 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef bytes _slice_bytes(grpc_slice slice): - cdef void *start = grpc_slice_start_ptr(slice) - cdef size_t length = grpc_slice_length(slice) - return (<const char *>start)[:length] - -cdef grpc_slice _copy_slice(grpc_slice slice) nogil: - cdef void *start = grpc_slice_start_ptr(slice) - cdef size_t length = grpc_slice_length(slice) - return grpc_slice_from_copied_buffer(<const char *>start, length) - -cdef grpc_slice _slice_from_bytes(bytes value) nogil: - cdef const char *value_ptr - cdef size_t length - with gil: - value_ptr = <const char *>value - length = len(value) - return grpc_slice_from_copied_buffer(value_ptr, length) - - +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef bytes _slice_bytes(grpc_slice slice): + cdef void *start = grpc_slice_start_ptr(slice) + cdef size_t length = grpc_slice_length(slice) + return (<const char *>start)[:length] + +cdef grpc_slice _copy_slice(grpc_slice slice) nogil: + cdef void *start = grpc_slice_start_ptr(slice) + cdef size_t length = grpc_slice_length(slice) + return grpc_slice_from_copied_buffer(<const char *>start, length) + +cdef grpc_slice _slice_from_bytes(bytes value) nogil: + cdef const char *value_ptr + cdef size_t length + with gil: + value_ptr = <const char *>value + length = len(value) + return grpc_slice_from_copied_buffer(value_ptr, length) + + class ConnectivityState: idle = GRPC_CHANNEL_IDLE connecting = GRPC_CHANNEL_CONNECTING @@ -141,15 +141,15 @@ cdef class CallDetails: @property def method(self): - return _slice_bytes(self.c_details.method) + return _slice_bytes(self.c_details.method) @property def host(self): - return _slice_bytes(self.c_details.host) + return _slice_bytes(self.c_details.host) @property def deadline(self): - return _time_from_timespec(self.c_details.deadline) + return _time_from_timespec(self.c_details.deadline) cdef class SslPemKeyCertPair: @@ -183,14 +183,14 @@ cdef class CompressionOptions: return result def to_channel_arg(self): - return ( - GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, - self.c_options.enabled_algorithms_bitset, - ) + return ( + GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, + self.c_options.enabled_algorithms_bitset, + ) def compression_algorithm_name(grpc_compression_algorithm algorithm): - cdef const char* name + cdef const char* name with nogil: grpc_compression_algorithm_name(algorithm, &name) # Let Cython do the right thing with string casting diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi index e6e79536bb..2b06557cbb 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pxd.pxi @@ -1,17 +1,17 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef grpc_ssl_roots_override_result ssl_roots_override_callback( - char **pem_root_certs) nogil + char **pem_root_certs) nogil diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi index 9cc3fd5a21..ae24cab9df 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/security.pyx.pxi @@ -1,85 +1,85 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. from libc.string cimport memcpy cdef grpc_ssl_roots_override_result ssl_roots_override_callback( - char **pem_root_certs) nogil: - with gil: - temporary_pem_root_certs = '' - pem_root_certs[0] = <char *>gpr_malloc(len(temporary_pem_root_certs) + 1) - memcpy( - pem_root_certs[0], <char *>temporary_pem_root_certs, - len(temporary_pem_root_certs)) - pem_root_certs[0][len(temporary_pem_root_certs)] = '\0' - + char **pem_root_certs) nogil: + with gil: + temporary_pem_root_certs = '' + pem_root_certs[0] = <char *>gpr_malloc(len(temporary_pem_root_certs) + 1) + memcpy( + pem_root_certs[0], <char *>temporary_pem_root_certs, + len(temporary_pem_root_certs)) + pem_root_certs[0][len(temporary_pem_root_certs)] = '\0' + return GRPC_SSL_ROOTS_OVERRIDE_OK - - -def peer_identities(Call call): - cdef grpc_auth_context* auth_context - cdef grpc_auth_property_iterator properties - cdef const grpc_auth_property* property - - auth_context = grpc_call_auth_context(call.c_call) - if auth_context == NULL: - return None - properties = grpc_auth_context_peer_identity(auth_context) - identities = [] - while True: - property = grpc_auth_property_iterator_next(&properties) - if property == NULL: - break - if property.value != NULL: - identities.append(<bytes>(property.value)) - grpc_auth_context_release(auth_context) - return identities if identities else None - -def peer_identity_key(Call call): - cdef grpc_auth_context* auth_context - cdef const char* c_key - auth_context = grpc_call_auth_context(call.c_call) - if auth_context == NULL: - return None - c_key = grpc_auth_context_peer_identity_property_name(auth_context) - if c_key == NULL: - key = None - else: - key = <bytes> grpc_auth_context_peer_identity_property_name(auth_context) - grpc_auth_context_release(auth_context) - return key - -def auth_context(Call call): - cdef grpc_auth_context* auth_context - cdef grpc_auth_property_iterator properties - cdef const grpc_auth_property* property - - auth_context = grpc_call_auth_context(call.c_call) - if auth_context == NULL: - return {} - properties = grpc_auth_context_property_iterator(auth_context) - py_auth_context = {} - while True: - property = grpc_auth_property_iterator_next(&properties) - if property == NULL: - break - if property.name != NULL and property.value != NULL: - key = <bytes> property.name - if key in py_auth_context: - py_auth_context[key].append(<bytes>(property.value)) - else: - py_auth_context[key] = [<bytes> property.value] - grpc_auth_context_release(auth_context) - return py_auth_context - + + +def peer_identities(Call call): + cdef grpc_auth_context* auth_context + cdef grpc_auth_property_iterator properties + cdef const grpc_auth_property* property + + auth_context = grpc_call_auth_context(call.c_call) + if auth_context == NULL: + return None + properties = grpc_auth_context_peer_identity(auth_context) + identities = [] + while True: + property = grpc_auth_property_iterator_next(&properties) + if property == NULL: + break + if property.value != NULL: + identities.append(<bytes>(property.value)) + grpc_auth_context_release(auth_context) + return identities if identities else None + +def peer_identity_key(Call call): + cdef grpc_auth_context* auth_context + cdef const char* c_key + auth_context = grpc_call_auth_context(call.c_call) + if auth_context == NULL: + return None + c_key = grpc_auth_context_peer_identity_property_name(auth_context) + if c_key == NULL: + key = None + else: + key = <bytes> grpc_auth_context_peer_identity_property_name(auth_context) + grpc_auth_context_release(auth_context) + return key + +def auth_context(Call call): + cdef grpc_auth_context* auth_context + cdef grpc_auth_property_iterator properties + cdef const grpc_auth_property* property + + auth_context = grpc_call_auth_context(call.c_call) + if auth_context == NULL: + return {} + properties = grpc_auth_context_property_iterator(auth_context) + py_auth_context = {} + while True: + property = grpc_auth_property_iterator_next(&properties) + if property == NULL: + break + if property.name != NULL and property.value != NULL: + key = <bytes> property.name + if key in py_auth_context: + py_auth_context[key].append(<bytes>(property.value)) + else: + py_auth_context[key] = [<bytes> property.value] + grpc_auth_context_release(auth_context) + return py_auth_context + diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi index b89ed99d97..60cd48a693 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef class Server: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index eff95c4f29..0c5b8fb680 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -1,21 +1,21 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. cdef class Server: - def __cinit__(self, object arguments): + def __cinit__(self, object arguments): fork_handlers_and_grpc_init() self.references = [] self.registered_completion_queues = [] @@ -34,15 +34,15 @@ cdef class Server: raise ValueError("server must be started and not shutting down") if server_queue not in self.registered_completion_queues: raise ValueError("server_queue must be a registered completion queue") - cdef _RequestCallTag request_call_tag = _RequestCallTag(tag) - request_call_tag.prepare() - cpython.Py_INCREF(request_call_tag) - return grpc_server_request_call( - self.c_server, &request_call_tag.call.c_call, - &request_call_tag.call_details.c_details, - &request_call_tag.c_invocation_metadata, - call_queue.c_completion_queue, server_queue.c_completion_queue, - <cpython.PyObject *>request_call_tag) + cdef _RequestCallTag request_call_tag = _RequestCallTag(tag) + request_call_tag.prepare() + cpython.Py_INCREF(request_call_tag) + return grpc_server_request_call( + self.c_server, &request_call_tag.call.c_call, + &request_call_tag.call_details.c_details, + &request_call_tag.c_invocation_metadata, + call_queue.c_completion_queue, server_queue.c_completion_queue, + <cpython.PyObject *>request_call_tag) def register_completion_queue( self, CompletionQueue queue not None): @@ -92,12 +92,12 @@ cdef class Server: cdef _c_shutdown(self, CompletionQueue queue, tag): self.is_shutting_down = True - cdef _ServerShutdownTag server_shutdown_tag = _ServerShutdownTag(tag, self) - cpython.Py_INCREF(server_shutdown_tag) + cdef _ServerShutdownTag server_shutdown_tag = _ServerShutdownTag(tag, self) + cpython.Py_INCREF(server_shutdown_tag) with nogil: grpc_server_shutdown_and_notify( self.c_server, queue.c_completion_queue, - <cpython.PyObject *>server_shutdown_tag) + <cpython.PyObject *>server_shutdown_tag) def shutdown(self, CompletionQueue queue not None, tag): if queue.is_shutting_down: @@ -112,8 +112,8 @@ cdef class Server: self._c_shutdown(queue, tag) cdef notify_shutdown_complete(self): - # called only after our server shutdown tag has emerged from a completion - # queue. + # called only after our server shutdown tag has emerged from a completion + # queue. self.is_shutdown = True def cancel_all_calls(self): diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi index d8ba1ea9bd..bd188d4a76 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pxd.pxi @@ -1,58 +1,58 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class _Tag: - - cdef object event(self, grpc_event c_event) - - -cdef class _ConnectivityTag(_Tag): - - cdef readonly object _user_tag - - cdef ConnectivityEvent event(self, grpc_event c_event) - - -cdef class _RequestCallTag(_Tag): - - cdef readonly object _user_tag - cdef Call call - cdef CallDetails call_details - cdef grpc_metadata_array c_invocation_metadata - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _Tag: + + cdef object event(self, grpc_event c_event) + + +cdef class _ConnectivityTag(_Tag): + + cdef readonly object _user_tag + + cdef ConnectivityEvent event(self, grpc_event c_event) + + +cdef class _RequestCallTag(_Tag): + + cdef readonly object _user_tag + cdef Call call + cdef CallDetails call_details + cdef grpc_metadata_array c_invocation_metadata + cdef void prepare(self) except * - cdef RequestCallEvent event(self, grpc_event c_event) - - -cdef class _BatchOperationTag(_Tag): - - cdef object _user_tag - cdef readonly object _operations - cdef readonly object _retained_call - cdef grpc_op *c_ops - cdef size_t c_nops - + cdef RequestCallEvent event(self, grpc_event c_event) + + +cdef class _BatchOperationTag(_Tag): + + cdef object _user_tag + cdef readonly object _operations + cdef readonly object _retained_call + cdef grpc_op *c_ops + cdef size_t c_nops + cdef void prepare(self) except * - cdef BatchOperationEvent event(self, grpc_event c_event) - - -cdef class _ServerShutdownTag(_Tag): - - cdef readonly object _user_tag - # This allows CompletionQueue to notify the Python Server object that the - # underlying GRPC core server has shutdown - cdef readonly Server _shutting_down_server - - cdef ServerShutdownEvent event(self, grpc_event c_event) + cdef BatchOperationEvent event(self, grpc_event c_event) + + +cdef class _ServerShutdownTag(_Tag): + + cdef readonly object _user_tag + # This allows CompletionQueue to notify the Python Server object that the + # underlying GRPC core server has shutdown + cdef readonly Server _shutting_down_server + + cdef ServerShutdownEvent event(self, grpc_event c_event) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi index e80dc88767..6bc74ea147 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/tag.pyx.pxi @@ -1,88 +1,88 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -cdef class _Tag: - - cdef object event(self, grpc_event c_event): - raise NotImplementedError() - - -cdef class _ConnectivityTag(_Tag): - - def __cinit__(self, user_tag): - self._user_tag = user_tag - - cdef ConnectivityEvent event(self, grpc_event c_event): - return ConnectivityEvent(c_event.type, c_event.success, self._user_tag) - - -cdef class _RequestCallTag(_Tag): - - def __cinit__(self, user_tag): - self._user_tag = user_tag - self.call = None - self.call_details = None - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +cdef class _Tag: + + cdef object event(self, grpc_event c_event): + raise NotImplementedError() + + +cdef class _ConnectivityTag(_Tag): + + def __cinit__(self, user_tag): + self._user_tag = user_tag + + cdef ConnectivityEvent event(self, grpc_event c_event): + return ConnectivityEvent(c_event.type, c_event.success, self._user_tag) + + +cdef class _RequestCallTag(_Tag): + + def __cinit__(self, user_tag): + self._user_tag = user_tag + self.call = None + self.call_details = None + cdef void prepare(self) except *: - self.call = Call() - self.call_details = CallDetails() - grpc_metadata_array_init(&self.c_invocation_metadata) - - cdef RequestCallEvent event(self, grpc_event c_event): - cdef tuple invocation_metadata = _metadata(&self.c_invocation_metadata) - grpc_metadata_array_destroy(&self.c_invocation_metadata) - return RequestCallEvent( - c_event.type, c_event.success, self._user_tag, self.call, - self.call_details, invocation_metadata) - - -cdef class _BatchOperationTag: - - def __cinit__(self, user_tag, operations, call): - self._user_tag = user_tag - self._operations = operations - self._retained_call = call - + self.call = Call() + self.call_details = CallDetails() + grpc_metadata_array_init(&self.c_invocation_metadata) + + cdef RequestCallEvent event(self, grpc_event c_event): + cdef tuple invocation_metadata = _metadata(&self.c_invocation_metadata) + grpc_metadata_array_destroy(&self.c_invocation_metadata) + return RequestCallEvent( + c_event.type, c_event.success, self._user_tag, self.call, + self.call_details, invocation_metadata) + + +cdef class _BatchOperationTag: + + def __cinit__(self, user_tag, operations, call): + self._user_tag = user_tag + self._operations = operations + self._retained_call = call + cdef void prepare(self) except *: cdef Operation operation - self.c_nops = 0 if self._operations is None else len(self._operations) - if 0 < self.c_nops: - self.c_ops = <grpc_op *>gpr_malloc(sizeof(grpc_op) * self.c_nops) - for index, operation in enumerate(self._operations): + self.c_nops = 0 if self._operations is None else len(self._operations) + if 0 < self.c_nops: + self.c_ops = <grpc_op *>gpr_malloc(sizeof(grpc_op) * self.c_nops) + for index, operation in enumerate(self._operations): operation.c() self.c_ops[index] = operation.c_op - - cdef BatchOperationEvent event(self, grpc_event c_event): + + cdef BatchOperationEvent event(self, grpc_event c_event): cdef Operation operation - if 0 < self.c_nops: + if 0 < self.c_nops: for operation in self._operations: operation.un_c() - gpr_free(self.c_ops) - return BatchOperationEvent( - c_event.type, c_event.success, self._user_tag, self._operations) - else: - return BatchOperationEvent( - c_event.type, c_event.success, self._user_tag, ()) - - -cdef class _ServerShutdownTag(_Tag): - - def __cinit__(self, user_tag, shutting_down_server): - self._user_tag = user_tag - self._shutting_down_server = shutting_down_server - - cdef ServerShutdownEvent event(self, grpc_event c_event): - self._shutting_down_server.notify_shutdown_complete() + gpr_free(self.c_ops) + return BatchOperationEvent( + c_event.type, c_event.success, self._user_tag, self._operations) + else: + return BatchOperationEvent( + c_event.type, c_event.success, self._user_tag, ()) + + +cdef class _ServerShutdownTag(_Tag): + + def __cinit__(self, user_tag, shutting_down_server): + self._user_tag = user_tag + self._shutting_down_server = shutting_down_server + + cdef ServerShutdownEvent event(self, grpc_event c_event): + self._shutting_down_server.notify_shutdown_complete() return ServerShutdownEvent(c_event.type, c_event.success, self._user_tag) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi index c46e8a98b0..b1495ac2ef 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pxd.pxi @@ -1,19 +1,19 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + cdef gpr_timespec _timespec_from_time(object time) except * - - + + cdef double _time_from_timespec(gpr_timespec timespec) except * diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi index 6d181bb1d6..a66ca571b7 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/_cygrpc/time.pyx.pxi @@ -1,29 +1,29 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + cdef gpr_timespec _timespec_from_time(object time) except *: - if time is None: - return gpr_inf_future(GPR_CLOCK_REALTIME) - else: + if time is None: + return gpr_inf_future(GPR_CLOCK_REALTIME) + else: return gpr_time_from_nanos( <int64_t>(<double>time * GPR_NS_PER_SEC), GPR_CLOCK_REALTIME, ) - - + + cdef double _time_from_timespec(gpr_timespec timespec) except *: - cdef gpr_timespec real_timespec = gpr_convert_clock_type( - timespec, GPR_CLOCK_REALTIME) + cdef gpr_timespec real_timespec = gpr_convert_clock_type( + timespec, GPR_CLOCK_REALTIME) return gpr_timespec_to_micros(real_timespec) / GPR_US_PER_SEC diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pxd b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pxd index 166be37022..03b71c7618 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pxd +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pxd @@ -1,39 +1,39 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# distutils: language=c++ +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# distutils: language=c++ cimport cpython include "_cygrpc/grpc.pxi" -include "_cygrpc/arguments.pxd.pxi" +include "_cygrpc/arguments.pxd.pxi" include "_cygrpc/call.pxd.pxi" include "_cygrpc/channel.pxd.pxi" include "_cygrpc/credentials.pxd.pxi" include "_cygrpc/completion_queue.pxd.pxi" -include "_cygrpc/event.pxd.pxi" -include "_cygrpc/metadata.pxd.pxi" -include "_cygrpc/operation.pxd.pxi" +include "_cygrpc/event.pxd.pxi" +include "_cygrpc/metadata.pxd.pxi" +include "_cygrpc/operation.pxd.pxi" include "_cygrpc/propagation_bits.pxd.pxi" include "_cygrpc/records.pxd.pxi" include "_cygrpc/security.pxd.pxi" include "_cygrpc/server.pxd.pxi" -include "_cygrpc/tag.pxd.pxi" -include "_cygrpc/time.pxd.pxi" +include "_cygrpc/tag.pxd.pxi" +include "_cygrpc/time.pxd.pxi" include "_cygrpc/vtable.pxd.pxi" include "_cygrpc/_hooks.pxd.pxi" - + include "_cygrpc/iomgr.pxd.pxi" include "_cygrpc/grpc_gevent.pxd.pxi" diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx index 8d355c6fbb..b3e7ebb69c 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -1,17 +1,17 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# distutils: language=c++ +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# distutils: language=c++ cimport cpython @@ -37,28 +37,28 @@ _LOGGER = logging.getLogger(__name__) # TODO(atash): figure out why the coverage tool gets confused about the Cython # coverage plugin when the following files don't have a '.pxi' suffix. include "_cygrpc/grpc_string.pyx.pxi" -include "_cygrpc/arguments.pyx.pxi" +include "_cygrpc/arguments.pyx.pxi" include "_cygrpc/call.pyx.pxi" include "_cygrpc/channel.pyx.pxi" include "_cygrpc/channelz.pyx.pxi" include "_cygrpc/credentials.pyx.pxi" include "_cygrpc/completion_queue.pyx.pxi" -include "_cygrpc/event.pyx.pxi" -include "_cygrpc/metadata.pyx.pxi" -include "_cygrpc/operation.pyx.pxi" +include "_cygrpc/event.pyx.pxi" +include "_cygrpc/metadata.pyx.pxi" +include "_cygrpc/operation.pyx.pxi" include "_cygrpc/propagation_bits.pyx.pxi" include "_cygrpc/records.pyx.pxi" include "_cygrpc/security.pyx.pxi" include "_cygrpc/server.pyx.pxi" -include "_cygrpc/tag.pyx.pxi" -include "_cygrpc/time.pyx.pxi" +include "_cygrpc/tag.pyx.pxi" +include "_cygrpc/time.pyx.pxi" include "_cygrpc/vtable.pyx.pxi" include "_cygrpc/_hooks.pyx.pxi" include "_cygrpc/iomgr.pyx.pxi" include "_cygrpc/grpc_gevent.pyx.pxi" - + include "_cygrpc/thread.pyx.pxi" IF UNAME_SYSNAME == "Windows": @@ -86,14 +86,14 @@ include "_cygrpc/aio/server.pyx.pxi" # cdef extern from "Python.h": - int PyEval_InitThreads() + int PyEval_InitThreads() -cdef _initialize(): - # We have Python callbacks called by c-core threads, this ensures the GIL - # is initialized. - PyEval_InitThreads() +cdef _initialize(): + # We have Python callbacks called by c-core threads, this ensures the GIL + # is initialized. + PyEval_InitThreads() import ssl grpc_dont_init_openssl() - # Load Arcadia certs in ComputePemRootCerts and do not override here. + # Load Arcadia certs in ComputePemRootCerts and do not override here. _initialize() diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_grpcio_metadata.py b/contrib/libs/grpc/src/python/grpcio/grpc/_grpcio_metadata.py index f5d0668407..a7e85e57e4 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_grpcio_metadata.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_grpcio_metadata.py @@ -1,17 +1,17 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! - +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!! + __version__ = """1.33.2""" diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_interceptor.py b/contrib/libs/grpc/src/python/grpcio/grpc/_interceptor.py index ee63cb3145..4317148196 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_interceptor.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_interceptor.py @@ -1,151 +1,151 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Implementation of gRPC Python interceptors.""" - -import collections -import sys - -import grpc - - -class _ServicePipeline(object): - - def __init__(self, interceptors): - self.interceptors = tuple(interceptors) - - def _continuation(self, thunk, index): - return lambda context: self._intercept_at(thunk, index, context) - - def _intercept_at(self, thunk, index, context): - if index < len(self.interceptors): - interceptor = self.interceptors[index] - thunk = self._continuation(thunk, index + 1) - return interceptor.intercept_service(thunk, context) - else: - return thunk(context) - - def execute(self, thunk, context): - return self._intercept_at(thunk, 0, context) - - -def service_pipeline(interceptors): - return _ServicePipeline(interceptors) if interceptors else None - - -class _ClientCallDetails( +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Implementation of gRPC Python interceptors.""" + +import collections +import sys + +import grpc + + +class _ServicePipeline(object): + + def __init__(self, interceptors): + self.interceptors = tuple(interceptors) + + def _continuation(self, thunk, index): + return lambda context: self._intercept_at(thunk, index, context) + + def _intercept_at(self, thunk, index, context): + if index < len(self.interceptors): + interceptor = self.interceptors[index] + thunk = self._continuation(thunk, index + 1) + return interceptor.intercept_service(thunk, context) + else: + return thunk(context) + + def execute(self, thunk, context): + return self._intercept_at(thunk, 0, context) + + +def service_pipeline(interceptors): + return _ServicePipeline(interceptors) if interceptors else None + + +class _ClientCallDetails( collections.namedtuple('_ClientCallDetails', ('method', 'timeout', 'metadata', 'credentials', 'wait_for_ready', 'compression')), - grpc.ClientCallDetails): - pass - - -def _unwrap_client_call_details(call_details, default_details): - try: - method = call_details.method - except AttributeError: - method = default_details.method - - try: - timeout = call_details.timeout - except AttributeError: - timeout = default_details.timeout - - try: - metadata = call_details.metadata - except AttributeError: - metadata = default_details.metadata - - try: - credentials = call_details.credentials - except AttributeError: - credentials = default_details.credentials - + grpc.ClientCallDetails): + pass + + +def _unwrap_client_call_details(call_details, default_details): + try: + method = call_details.method + except AttributeError: + method = default_details.method + + try: + timeout = call_details.timeout + except AttributeError: + timeout = default_details.timeout + + try: + metadata = call_details.metadata + except AttributeError: + metadata = default_details.metadata + + try: + credentials = call_details.credentials + except AttributeError: + credentials = default_details.credentials + try: wait_for_ready = call_details.wait_for_ready except AttributeError: wait_for_ready = default_details.wait_for_ready - + try: compression = call_details.compression except AttributeError: compression = default_details.compression - + return method, timeout, metadata, credentials, wait_for_ready, compression - + class _FailureOutcome(grpc.RpcError, grpc.Future, grpc.Call): # pylint: disable=too-many-ancestors - def __init__(self, exception, traceback): + def __init__(self, exception, traceback): super(_FailureOutcome, self).__init__() - self._exception = exception - self._traceback = traceback - - def initial_metadata(self): - return None - - def trailing_metadata(self): - return None - - def code(self): - return grpc.StatusCode.INTERNAL - - def details(self): - return 'Exception raised while intercepting the RPC' - - def cancel(self): - return False - - def cancelled(self): - return False - + self._exception = exception + self._traceback = traceback + + def initial_metadata(self): + return None + + def trailing_metadata(self): + return None + + def code(self): + return grpc.StatusCode.INTERNAL + + def details(self): + return 'Exception raised while intercepting the RPC' + + def cancel(self): + return False + + def cancelled(self): + return False + def is_active(self): return False def time_remaining(self): return None - def running(self): - return False - - def done(self): - return True - - def result(self, ignored_timeout=None): - raise self._exception - - def exception(self, ignored_timeout=None): - return self._exception - - def traceback(self, ignored_timeout=None): - return self._traceback - + def running(self): + return False + + def done(self): + return True + + def result(self, ignored_timeout=None): + raise self._exception + + def exception(self, ignored_timeout=None): + return self._exception + + def traceback(self, ignored_timeout=None): + return self._traceback + def add_callback(self, unused_callback): return False - def add_done_callback(self, fn): - fn(self) - - def __iter__(self): - return self - + def add_done_callback(self, fn): + fn(self) + + def __iter__(self): + return self + def __next__(self): - raise self._exception - + raise self._exception + def next(self): return self.__next__() - + class _UnaryOutcome(grpc.Call, grpc.Future): @@ -199,13 +199,13 @@ class _UnaryOutcome(grpc.Call, grpc.Future): fn(self) -class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): - - def __init__(self, thunk, method, interceptor): - self._thunk = thunk - self._method = method - self._interceptor = interceptor - +class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): + + def __init__(self, thunk, method, interceptor): + self._thunk = thunk + self._method = method + self._interceptor = interceptor + def __call__(self, request, timeout=None, @@ -220,7 +220,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): wait_for_ready=wait_for_ready, compression=compression) return response - + def _with_call(self, request, timeout=None, @@ -269,7 +269,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): credentials=credentials, wait_for_ready=wait_for_ready, compression=compression) - + def future(self, request, timeout=None, @@ -280,34 +280,34 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials, wait_for_ready, compression) - - def continuation(new_details, request): + + def continuation(new_details, request): (new_method, new_timeout, new_metadata, new_credentials, new_wait_for_ready, new_compression) = (_unwrap_client_call_details( new_details, client_call_details)) - return self._thunk(new_method).future( - request, - timeout=new_timeout, - metadata=new_metadata, + return self._thunk(new_method).future( + request, + timeout=new_timeout, + metadata=new_metadata, credentials=new_credentials, wait_for_ready=new_wait_for_ready, compression=new_compression) - - try: - return self._interceptor.intercept_unary_unary( - continuation, client_call_details, request) - except Exception as exception: # pylint:disable=broad-except + + try: + return self._interceptor.intercept_unary_unary( + continuation, client_call_details, request) + except Exception as exception: # pylint:disable=broad-except return _FailureOutcome(exception, sys.exc_info()[2]) - - -class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): - - def __init__(self, thunk, method, interceptor): - self._thunk = thunk - self._method = method - self._interceptor = interceptor - + + +class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): + + def __init__(self, thunk, method, interceptor): + self._thunk = thunk + self._method = method + self._interceptor = interceptor + def __call__(self, request, timeout=None, @@ -318,8 +318,8 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials, wait_for_ready, compression) - - def continuation(new_details, request): + + def continuation(new_details, request): (new_method, new_timeout, new_metadata, new_credentials, new_wait_for_ready, new_compression) = (_unwrap_client_call_details( @@ -330,25 +330,25 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): credentials=new_credentials, wait_for_ready=new_wait_for_ready, compression=new_compression) - - try: - return self._interceptor.intercept_unary_stream( - continuation, client_call_details, request) - except Exception as exception: # pylint:disable=broad-except + + try: + return self._interceptor.intercept_unary_stream( + continuation, client_call_details, request) + except Exception as exception: # pylint:disable=broad-except return _FailureOutcome(exception, sys.exc_info()[2]) - - -class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): - - def __init__(self, thunk, method, interceptor): - self._thunk = thunk - self._method = method - self._interceptor = interceptor - - def __call__(self, - request_iterator, - timeout=None, - metadata=None, + + +class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): + + def __init__(self, thunk, method, interceptor): + self._thunk = thunk + self._method = method + self._interceptor = interceptor + + def __call__(self, + request_iterator, + timeout=None, + metadata=None, credentials=None, wait_for_ready=None, compression=None): @@ -359,7 +359,7 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): wait_for_ready=wait_for_ready, compression=compression) return response - + def _with_call(self, request_iterator, timeout=None, @@ -395,10 +395,10 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): request_iterator) return call.result(), call - def with_call(self, - request_iterator, - timeout=None, - metadata=None, + def with_call(self, + request_iterator, + timeout=None, + metadata=None, credentials=None, wait_for_ready=None, compression=None): @@ -408,57 +408,57 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): credentials=credentials, wait_for_ready=wait_for_ready, compression=compression) - - def future(self, - request_iterator, - timeout=None, - metadata=None, + + def future(self, + request_iterator, + timeout=None, + metadata=None, credentials=None, wait_for_ready=None, compression=None): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials, wait_for_ready, compression) - - def continuation(new_details, request_iterator): + + def continuation(new_details, request_iterator): (new_method, new_timeout, new_metadata, new_credentials, new_wait_for_ready, new_compression) = (_unwrap_client_call_details( new_details, client_call_details)) - return self._thunk(new_method).future( - request_iterator, - timeout=new_timeout, - metadata=new_metadata, + return self._thunk(new_method).future( + request_iterator, + timeout=new_timeout, + metadata=new_metadata, credentials=new_credentials, wait_for_ready=new_wait_for_ready, compression=new_compression) - - try: - return self._interceptor.intercept_stream_unary( - continuation, client_call_details, request_iterator) - except Exception as exception: # pylint:disable=broad-except + + try: + return self._interceptor.intercept_stream_unary( + continuation, client_call_details, request_iterator) + except Exception as exception: # pylint:disable=broad-except return _FailureOutcome(exception, sys.exc_info()[2]) - - -class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): - - def __init__(self, thunk, method, interceptor): - self._thunk = thunk - self._method = method - self._interceptor = interceptor - - def __call__(self, - request_iterator, - timeout=None, - metadata=None, + + +class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): + + def __init__(self, thunk, method, interceptor): + self._thunk = thunk + self._method = method + self._interceptor = interceptor + + def __call__(self, + request_iterator, + timeout=None, + metadata=None, credentials=None, wait_for_ready=None, compression=None): client_call_details = _ClientCallDetails(self._method, timeout, metadata, credentials, wait_for_ready, compression) - - def continuation(new_details, request_iterator): + + def continuation(new_details, request_iterator): (new_method, new_timeout, new_metadata, new_credentials, new_wait_for_ready, new_compression) = (_unwrap_client_call_details( @@ -469,94 +469,94 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): credentials=new_credentials, wait_for_ready=new_wait_for_ready, compression=new_compression) - - try: - return self._interceptor.intercept_stream_stream( - continuation, client_call_details, request_iterator) - except Exception as exception: # pylint:disable=broad-except + + try: + return self._interceptor.intercept_stream_stream( + continuation, client_call_details, request_iterator) + except Exception as exception: # pylint:disable=broad-except return _FailureOutcome(exception, sys.exc_info()[2]) - - -class _Channel(grpc.Channel): - - def __init__(self, channel, interceptor): - self._channel = channel - self._interceptor = interceptor - + + +class _Channel(grpc.Channel): + + def __init__(self, channel, interceptor): + self._channel = channel + self._interceptor = interceptor + def subscribe(self, callback, try_to_connect=False): self._channel.subscribe(callback, try_to_connect=try_to_connect) - + def unsubscribe(self, callback): self._channel.unsubscribe(callback) - - def unary_unary(self, - method, - request_serializer=None, - response_deserializer=None): + + def unary_unary(self, + method, + request_serializer=None, + response_deserializer=None): thunk = lambda m: self._channel.unary_unary(m, request_serializer, response_deserializer) - if isinstance(self._interceptor, grpc.UnaryUnaryClientInterceptor): - return _UnaryUnaryMultiCallable(thunk, method, self._interceptor) - else: - return thunk(method) - - def unary_stream(self, - method, - request_serializer=None, - response_deserializer=None): + if isinstance(self._interceptor, grpc.UnaryUnaryClientInterceptor): + return _UnaryUnaryMultiCallable(thunk, method, self._interceptor) + else: + return thunk(method) + + def unary_stream(self, + method, + request_serializer=None, + response_deserializer=None): thunk = lambda m: self._channel.unary_stream(m, request_serializer, response_deserializer) - if isinstance(self._interceptor, grpc.UnaryStreamClientInterceptor): - return _UnaryStreamMultiCallable(thunk, method, self._interceptor) - else: - return thunk(method) - - def stream_unary(self, - method, - request_serializer=None, - response_deserializer=None): + if isinstance(self._interceptor, grpc.UnaryStreamClientInterceptor): + return _UnaryStreamMultiCallable(thunk, method, self._interceptor) + else: + return thunk(method) + + def stream_unary(self, + method, + request_serializer=None, + response_deserializer=None): thunk = lambda m: self._channel.stream_unary(m, request_serializer, response_deserializer) - if isinstance(self._interceptor, grpc.StreamUnaryClientInterceptor): - return _StreamUnaryMultiCallable(thunk, method, self._interceptor) - else: - return thunk(method) - - def stream_stream(self, - method, - request_serializer=None, - response_deserializer=None): + if isinstance(self._interceptor, grpc.StreamUnaryClientInterceptor): + return _StreamUnaryMultiCallable(thunk, method, self._interceptor) + else: + return thunk(method) + + def stream_stream(self, + method, + request_serializer=None, + response_deserializer=None): thunk = lambda m: self._channel.stream_stream(m, request_serializer, response_deserializer) - if isinstance(self._interceptor, grpc.StreamStreamClientInterceptor): - return _StreamStreamMultiCallable(thunk, method, self._interceptor) - else: - return thunk(method) - - def _close(self): - self._channel.close() - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - self._close() - return False - - def close(self): - self._channel.close() - - -def intercept_channel(channel, *interceptors): - for interceptor in reversed(list(interceptors)): - if not isinstance(interceptor, grpc.UnaryUnaryClientInterceptor) and \ - not isinstance(interceptor, grpc.UnaryStreamClientInterceptor) and \ - not isinstance(interceptor, grpc.StreamUnaryClientInterceptor) and \ - not isinstance(interceptor, grpc.StreamStreamClientInterceptor): - raise TypeError('interceptor must be ' - 'grpc.UnaryUnaryClientInterceptor or ' - 'grpc.UnaryStreamClientInterceptor or ' - 'grpc.StreamUnaryClientInterceptor or ' - 'grpc.StreamStreamClientInterceptor or ') - channel = _Channel(channel, interceptor) - return channel + if isinstance(self._interceptor, grpc.StreamStreamClientInterceptor): + return _StreamStreamMultiCallable(thunk, method, self._interceptor) + else: + return thunk(method) + + def _close(self): + self._channel.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self._close() + return False + + def close(self): + self._channel.close() + + +def intercept_channel(channel, *interceptors): + for interceptor in reversed(list(interceptors)): + if not isinstance(interceptor, grpc.UnaryUnaryClientInterceptor) and \ + not isinstance(interceptor, grpc.UnaryStreamClientInterceptor) and \ + not isinstance(interceptor, grpc.StreamUnaryClientInterceptor) and \ + not isinstance(interceptor, grpc.StreamStreamClientInterceptor): + raise TypeError('interceptor must be ' + 'grpc.UnaryUnaryClientInterceptor or ' + 'grpc.UnaryStreamClientInterceptor or ' + 'grpc.StreamUnaryClientInterceptor or ' + 'grpc.StreamStreamClientInterceptor or ') + channel = _Channel(channel, interceptor) + return channel diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_plugin_wrapping.py b/contrib/libs/grpc/src/python/grpcio/grpc/_plugin_wrapping.py index e3bfa90916..9be507027f 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_plugin_wrapping.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_plugin_wrapping.py @@ -1,19 +1,19 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import collections -import logging +import logging import threading import grpc @@ -23,79 +23,79 @@ from grpc._cython import cygrpc _LOGGER = logging.getLogger(__name__) -class _AuthMetadataContext( +class _AuthMetadataContext( collections.namedtuple('AuthMetadataContext', ( - 'service_url', - 'method_name', - )), grpc.AuthMetadataContext): + 'service_url', + 'method_name', + )), grpc.AuthMetadataContext): pass -class _CallbackState(object): +class _CallbackState(object): - def __init__(self): - self.lock = threading.Lock() - self.called = False - self.exception = None + def __init__(self): + self.lock = threading.Lock() + self.called = False + self.exception = None -class _AuthMetadataPluginCallback(grpc.AuthMetadataPluginCallback): +class _AuthMetadataPluginCallback(grpc.AuthMetadataPluginCallback): - def __init__(self, state, callback): - self._state = state - self._callback = callback + def __init__(self, state, callback): + self._state = state + self._callback = callback def __call__(self, metadata, error): - with self._state.lock: - if self._state.exception is None: - if self._state.called: - raise RuntimeError( - 'AuthMetadataPluginCallback invoked more than once!') - else: - self._state.called = True - else: - raise RuntimeError( - 'AuthMetadataPluginCallback raised exception "{}"!'.format( - self._state.exception)) + with self._state.lock: + if self._state.exception is None: + if self._state.called: + raise RuntimeError( + 'AuthMetadataPluginCallback invoked more than once!') + else: + self._state.called = True + else: + raise RuntimeError( + 'AuthMetadataPluginCallback raised exception "{}"!'.format( + self._state.exception)) if error is None: - self._callback(metadata, cygrpc.StatusCode.ok, None) + self._callback(metadata, cygrpc.StatusCode.ok, None) else: - self._callback(None, cygrpc.StatusCode.internal, - _common.encode(str(error))) + self._callback(None, cygrpc.StatusCode.internal, + _common.encode(str(error))) -class _Plugin(object): +class _Plugin(object): - def __init__(self, metadata_plugin): - self._metadata_plugin = metadata_plugin + def __init__(self, metadata_plugin): + self._metadata_plugin = metadata_plugin - def __call__(self, service_url, method_name, callback): + def __call__(self, service_url, method_name, callback): context = _AuthMetadataContext(_common.decode(service_url), _common.decode(method_name)) - callback_state = _CallbackState() + callback_state = _CallbackState() try: self._metadata_plugin( context, _AuthMetadataPluginCallback(callback_state, callback)) - except Exception as exception: # pylint: disable=broad-except + except Exception as exception: # pylint: disable=broad-except _LOGGER.exception( - 'AuthMetadataPluginCallback "%s" raised exception!', - self._metadata_plugin) - with callback_state.lock: - callback_state.exception = exception - if callback_state.called: - return - callback(None, cygrpc.StatusCode.internal, - _common.encode(str(exception))) - - -def metadata_plugin_call_credentials(metadata_plugin, name): - if name is None: - try: - effective_name = metadata_plugin.__name__ - except AttributeError: - effective_name = metadata_plugin.__class__.__name__ - else: - effective_name = name - return grpc.CallCredentials( + 'AuthMetadataPluginCallback "%s" raised exception!', + self._metadata_plugin) + with callback_state.lock: + callback_state.exception = exception + if callback_state.called: + return + callback(None, cygrpc.StatusCode.internal, + _common.encode(str(exception))) + + +def metadata_plugin_call_credentials(metadata_plugin, name): + if name is None: + try: + effective_name = metadata_plugin.__name__ + except AttributeError: + effective_name = metadata_plugin.__class__.__name__ + else: + effective_name = name + return grpc.CallCredentials( cygrpc.MetadataPluginCallCredentials(_Plugin(metadata_plugin), _common.encode(effective_name))) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_server.py b/contrib/libs/grpc/src/python/grpcio/grpc/_server.py index 48ff743995..8a0cddbeed 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_server.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_server.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Service-side implementation of gRPC Python.""" import collections @@ -20,12 +20,12 @@ import threading import time from concurrent import futures -import six - +import six + import grpc from grpc import _common from grpc import _compression -from grpc import _interceptor +from grpc import _interceptor from grpc._cython import cygrpc _LOGGER = logging.getLogger(__name__) @@ -54,7 +54,7 @@ _INF_TIMEOUT = 1e9 def _serialized_request(request_event): - return request_event.batch_operations[0].message() + return request_event.batch_operations[0].message() def _application_code(code): @@ -82,9 +82,9 @@ def _details(state): class _HandlerCallDetails( collections.namedtuple('_HandlerCallDetails', ( - 'method', - 'invocation_metadata', - )), grpc.HandlerCallDetails): + 'method', + 'invocation_metadata', + )), grpc.HandlerCallDetails): pass @@ -157,21 +157,21 @@ def _abort(state, call, code, details): effective_code = _abortion_code(state, code) effective_details = details if state.details is None else state.details if state.initial_metadata_allowed: - operations = ( + operations = ( _get_initial_metadata_operation(state, None), cygrpc.SendStatusFromServerOperation(state.trailing_metadata, effective_code, effective_details, _EMPTY_FLAGS), - ) + ) token = _SEND_INITIAL_METADATA_AND_SEND_STATUS_FROM_SERVER_TOKEN else: - operations = (cygrpc.SendStatusFromServerOperation( - state.trailing_metadata, effective_code, effective_details, - _EMPTY_FLAGS),) + operations = (cygrpc.SendStatusFromServerOperation( + state.trailing_metadata, effective_code, effective_details, + _EMPTY_FLAGS),) token = _SEND_STATUS_FROM_SERVER_TOKEN - call.start_server_batch(operations, - _send_status_from_server(state, token)) + call.start_server_batch(operations, + _send_status_from_server(state, token)) state.statused = True state.due.add(token) @@ -180,7 +180,7 @@ def _receive_close_on_server(state): def receive_close_on_server(receive_close_on_server_event): with state.condition: - if receive_close_on_server_event.batch_operations[0].cancelled(): + if receive_close_on_server_event.batch_operations[0].cancelled(): state.client = _CANCELLED elif state.client is _OPEN: state.client = _CLOSED @@ -246,10 +246,10 @@ class _Context(grpc.ServicerContext): return _is_rpc_state_active(self._state) def time_remaining(self): - return max(self._rpc_event.call_details.deadline - time.time(), 0) + return max(self._rpc_event.call_details.deadline - time.time(), 0) def cancel(self): - self._rpc_event.call.cancel() + self._rpc_event.call.cancel() def add_callback(self, callback): with self._state.condition: @@ -264,24 +264,24 @@ class _Context(grpc.ServicerContext): self._state.disable_next_compression = True def invocation_metadata(self): - return self._rpc_event.invocation_metadata + return self._rpc_event.invocation_metadata def peer(self): - return _common.decode(self._rpc_event.call.peer()) - - def peer_identities(self): - return cygrpc.peer_identities(self._rpc_event.call) - - def peer_identity_key(self): - id_key = cygrpc.peer_identity_key(self._rpc_event.call) - return id_key if id_key is None else _common.decode(id_key) - - def auth_context(self): - return { + return _common.decode(self._rpc_event.call.peer()) + + def peer_identities(self): + return cygrpc.peer_identities(self._rpc_event.call) + + def peer_identity_key(self): + id_key = cygrpc.peer_identity_key(self._rpc_event.call) + return id_key if id_key is None else _common.decode(id_key) + + def auth_context(self): + return { _common.decode(key): value for key, value in six.iteritems( - cygrpc.auth_context(self._rpc_event.call)) - } - + cygrpc.auth_context(self._rpc_event.call)) + } + def set_compression(self, compression): with self._state.condition: self._state.compression_algorithm = compression @@ -294,8 +294,8 @@ class _Context(grpc.ServicerContext): if self._state.initial_metadata_allowed: operation = _get_initial_metadata_operation( self._state, initial_metadata) - self._rpc_event.call.start_server_batch( - (operation,), _send_initial_metadata(self._state)) + self._rpc_event.call.start_server_batch( + (operation,), _send_initial_metadata(self._state)) self._state.initial_metadata_allowed = False self._state.due.add(_SEND_INITIAL_METADATA_TOKEN) else: @@ -303,21 +303,21 @@ class _Context(grpc.ServicerContext): def set_trailing_metadata(self, trailing_metadata): with self._state.condition: - self._state.trailing_metadata = trailing_metadata + self._state.trailing_metadata = trailing_metadata - def abort(self, code, details): - # treat OK like other invalid arguments: fail the RPC - if code == grpc.StatusCode.OK: + def abort(self, code, details): + # treat OK like other invalid arguments: fail the RPC + if code == grpc.StatusCode.OK: _LOGGER.error( - 'abort() called with StatusCode.OK; returning UNKNOWN') - code = grpc.StatusCode.UNKNOWN - details = '' - with self._state.condition: - self._state.code = code - self._state.details = _common.encode(details) + 'abort() called with StatusCode.OK; returning UNKNOWN') + code = grpc.StatusCode.UNKNOWN + details = '' + with self._state.condition: + self._state.code = code + self._state.details = _common.encode(details) self._state.aborted = True raise Exception() - + def abort_with_status(self, status): self._state.trailing_metadata = status.trailing_metadata self.abort(status.code, status.details) @@ -348,7 +348,7 @@ class _RequestIterator(object): raise StopIteration() else: self._call.start_server_batch( - (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), + (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), _receive_message(self._state, self._call, self._request_deserializer)) self._state.due.add(_RECEIVE_MESSAGE_TOKEN) @@ -392,9 +392,9 @@ def _unary_request(rpc_event, state, request_deserializer): if not _is_rpc_state_active(state): return None else: - rpc_event.call.start_server_batch( - (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), - _receive_message(state, rpc_event.call, + rpc_event.call.start_server_batch( + (cygrpc.ReceiveMessageOperation(_EMPTY_FLAGS),), + _receive_message(state, rpc_event.call, request_deserializer)) state.due.add(_RECEIVE_MESSAGE_TOKEN) while True: @@ -402,8 +402,8 @@ def _unary_request(rpc_event, state, request_deserializer): if state.request is None: if state.client is _CLOSED: details = '"{}" requires exactly one request message.'.format( - rpc_event.call_details.method) - _abort(state, rpc_event.call, + rpc_event.call_details.method) + _abort(state, rpc_event.call, cygrpc.StatusCode.unimplemented, _common.encode(details)) return None @@ -453,16 +453,16 @@ def _take_response_from_response_iterator(rpc_event, state, response_iterator): return next(response_iterator), True except StopIteration: return None, True - except Exception as exception: # pylint: disable=broad-except + except Exception as exception: # pylint: disable=broad-except with state.condition: if state.aborted: - _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, - b'RPC Aborted') - elif exception not in state.rpc_errors: - details = 'Exception iterating responses: {}'.format(exception) + _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, + b'RPC Aborted') + elif exception not in state.rpc_errors: + details = 'Exception iterating responses: {}'.format(exception) _LOGGER.exception(details) - _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, - _common.encode(details)) + _abort(state, rpc_event.call, cygrpc.StatusCode.unknown, + _common.encode(details)) return None, False @@ -470,7 +470,7 @@ def _serialize_response(rpc_event, state, response, response_serializer): serialized_response = _common.serialize(response, response_serializer) if serialized_response is None: with state.condition: - _abort(state, rpc_event.call, cygrpc.StatusCode.internal, + _abort(state, rpc_event.call, cygrpc.StatusCode.internal, b'Failed to serialize response!') return None else: @@ -495,21 +495,21 @@ def _send_response(rpc_event, state, serialized_response): return False else: if state.initial_metadata_allowed: - operations = ( + operations = ( _get_initial_metadata_operation(state, None), cygrpc.SendMessageOperation( serialized_response, _get_send_message_op_flags_from_state(state)), - ) + ) state.initial_metadata_allowed = False token = _SEND_INITIAL_METADATA_AND_SEND_MESSAGE_TOKEN else: - operations = (cygrpc.SendMessageOperation( + operations = (cygrpc.SendMessageOperation( serialized_response, _get_send_message_op_flags_from_state(state)),) token = _SEND_MESSAGE_TOKEN - rpc_event.call.start_server_batch(operations, - _send_message(state, token)) + rpc_event.call.start_server_batch(operations, + _send_message(state, token)) state.due.add(token) _reset_per_message_state(state) while True: @@ -535,8 +535,8 @@ def _status(rpc_event, state, serialized_response): cygrpc.SendMessageOperation( serialized_response, _get_send_message_op_flags_from_state(state))) - rpc_event.call.start_server_batch( - operations, + rpc_event.call.start_server_batch( + operations, _send_status_from_server(state, _SEND_STATUS_FROM_SERVER_TOKEN)) state.statused = True _reset_per_message_state(state) @@ -626,10 +626,10 @@ def _handle_unary_unary(rpc_event, state, method_handler, default_thread_pool): method_handler.request_deserializer) thread_pool = _select_thread_pool_for_behavior(method_handler.unary_unary, default_thread_pool) - return thread_pool.submit(_unary_response_in_pool, rpc_event, state, - method_handler.unary_unary, unary_request, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit(_unary_response_in_pool, rpc_event, state, + method_handler.unary_unary, unary_request, + method_handler.request_deserializer, + method_handler.response_serializer) def _handle_unary_stream(rpc_event, state, method_handler, default_thread_pool): @@ -637,14 +637,14 @@ def _handle_unary_stream(rpc_event, state, method_handler, default_thread_pool): method_handler.request_deserializer) thread_pool = _select_thread_pool_for_behavior(method_handler.unary_stream, default_thread_pool) - return thread_pool.submit(_stream_response_in_pool, rpc_event, state, - method_handler.unary_stream, unary_request, - method_handler.request_deserializer, - method_handler.response_serializer) + return thread_pool.submit(_stream_response_in_pool, rpc_event, state, + method_handler.unary_stream, unary_request, + method_handler.request_deserializer, + method_handler.response_serializer) def _handle_stream_unary(rpc_event, state, method_handler, default_thread_pool): - request_iterator = _RequestIterator(state, rpc_event.call, + request_iterator = _RequestIterator(state, rpc_event.call, method_handler.request_deserializer) thread_pool = _select_thread_pool_for_behavior(method_handler.stream_unary, default_thread_pool) @@ -657,7 +657,7 @@ def _handle_stream_unary(rpc_event, state, method_handler, default_thread_pool): def _handle_stream_stream(rpc_event, state, method_handler, default_thread_pool): - request_iterator = _RequestIterator(state, rpc_event.call, + request_iterator = _RequestIterator(state, rpc_event.call, method_handler.request_deserializer) thread_pool = _select_thread_pool_for_behavior(method_handler.stream_stream, default_thread_pool) @@ -668,34 +668,34 @@ def _handle_stream_stream(rpc_event, state, method_handler, method_handler.response_serializer) -def _find_method_handler(rpc_event, generic_handlers, interceptor_pipeline): - - def query_handlers(handler_call_details): - for generic_handler in generic_handlers: - method_handler = generic_handler.service(handler_call_details) - if method_handler is not None: - return method_handler +def _find_method_handler(rpc_event, generic_handlers, interceptor_pipeline): + + def query_handlers(handler_call_details): + for generic_handler in generic_handlers: + method_handler = generic_handler.service(handler_call_details) + if method_handler is not None: + return method_handler return None - handler_call_details = _HandlerCallDetails( - _common.decode(rpc_event.call_details.method), - rpc_event.invocation_metadata) - - if interceptor_pipeline is not None: - return interceptor_pipeline.execute(query_handlers, - handler_call_details) - else: - return query_handlers(handler_call_details) - - -def _reject_rpc(rpc_event, status, details): + handler_call_details = _HandlerCallDetails( + _common.decode(rpc_event.call_details.method), + rpc_event.invocation_metadata) + + if interceptor_pipeline is not None: + return interceptor_pipeline.execute(query_handlers, + handler_call_details) + else: + return query_handlers(handler_call_details) + + +def _reject_rpc(rpc_event, status, details): rpc_state = _RPCState() operations = ( _get_initial_metadata_operation(rpc_state, None), - cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS), - cygrpc.SendStatusFromServerOperation(None, status, details, - _EMPTY_FLAGS), - ) + cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS), + cygrpc.SendStatusFromServerOperation(None, status, details, + _EMPTY_FLAGS), + ) rpc_event.call.start_server_batch(operations, lambda ignored_event: ( rpc_state, (), @@ -706,50 +706,50 @@ def _reject_rpc(rpc_event, status, details): def _handle_with_method_handler(rpc_event, method_handler, thread_pool): state = _RPCState() with state.condition: - rpc_event.call.start_server_batch( - (cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),), + rpc_event.call.start_server_batch( + (cygrpc.ReceiveCloseOnServerOperation(_EMPTY_FLAGS),), _receive_close_on_server(state)) state.due.add(_RECEIVE_CLOSE_ON_SERVER_TOKEN) if method_handler.request_streaming: if method_handler.response_streaming: - return state, _handle_stream_stream(rpc_event, state, - method_handler, thread_pool) + return state, _handle_stream_stream(rpc_event, state, + method_handler, thread_pool) else: - return state, _handle_stream_unary(rpc_event, state, - method_handler, thread_pool) + return state, _handle_stream_unary(rpc_event, state, + method_handler, thread_pool) else: if method_handler.response_streaming: - return state, _handle_unary_stream(rpc_event, state, - method_handler, thread_pool) + return state, _handle_unary_stream(rpc_event, state, + method_handler, thread_pool) else: - return state, _handle_unary_unary(rpc_event, state, - method_handler, thread_pool) - - -def _handle_call(rpc_event, generic_handlers, interceptor_pipeline, thread_pool, - concurrency_exceeded): - if not rpc_event.success: - return None, None - if rpc_event.call_details.method is not None: - try: - method_handler = _find_method_handler(rpc_event, generic_handlers, - interceptor_pipeline) - except Exception as exception: # pylint: disable=broad-except - details = 'Exception servicing handler: {}'.format(exception) + return state, _handle_unary_unary(rpc_event, state, + method_handler, thread_pool) + + +def _handle_call(rpc_event, generic_handlers, interceptor_pipeline, thread_pool, + concurrency_exceeded): + if not rpc_event.success: + return None, None + if rpc_event.call_details.method is not None: + try: + method_handler = _find_method_handler(rpc_event, generic_handlers, + interceptor_pipeline) + except Exception as exception: # pylint: disable=broad-except + details = 'Exception servicing handler: {}'.format(exception) _LOGGER.exception(details) - return _reject_rpc(rpc_event, cygrpc.StatusCode.unknown, - b'Error in service handler!'), None + return _reject_rpc(rpc_event, cygrpc.StatusCode.unknown, + b'Error in service handler!'), None if method_handler is None: - return _reject_rpc(rpc_event, cygrpc.StatusCode.unimplemented, - b'Method not found!'), None - elif concurrency_exceeded: - return _reject_rpc(rpc_event, cygrpc.StatusCode.resource_exhausted, - b'Concurrent RPC limit exceeded!'), None + return _reject_rpc(rpc_event, cygrpc.StatusCode.unimplemented, + b'Method not found!'), None + elif concurrency_exceeded: + return _reject_rpc(rpc_event, cygrpc.StatusCode.resource_exhausted, + b'Concurrent RPC limit exceeded!'), None else: return _handle_with_method_handler(rpc_event, method_handler, thread_pool) else: - return None, None + return None, None @enum.unique @@ -761,20 +761,20 @@ class _ServerStage(enum.Enum): class _ServerState(object): - # pylint: disable=too-many-arguments - def __init__(self, completion_queue, server, generic_handlers, - interceptor_pipeline, thread_pool, maximum_concurrent_rpcs): - self.lock = threading.RLock() + # pylint: disable=too-many-arguments + def __init__(self, completion_queue, server, generic_handlers, + interceptor_pipeline, thread_pool, maximum_concurrent_rpcs): + self.lock = threading.RLock() self.completion_queue = completion_queue self.server = server self.generic_handlers = list(generic_handlers) - self.interceptor_pipeline = interceptor_pipeline + self.interceptor_pipeline = interceptor_pipeline self.thread_pool = thread_pool self.stage = _ServerStage.STOPPED self.termination_event = threading.Event() self.shutdown_events = [self.termination_event] - self.maximum_concurrent_rpcs = maximum_concurrent_rpcs - self.active_rpc_count = 0 + self.maximum_concurrent_rpcs = maximum_concurrent_rpcs + self.active_rpc_count = 0 # TODO(https://github.com/grpc/grpc/issues/6597): eliminate these fields. self.rpc_states = set() @@ -818,11 +818,11 @@ def _stop_serving(state): return False -def _on_call_completed(state): - with state.lock: - state.active_rpc_count -= 1 - - +def _on_call_completed(state): + with state.lock: + state.active_rpc_count -= 1 + + def _process_event_and_continue(state, event): should_continue = True if event.tag is _SHUTDOWN_TAG: @@ -874,10 +874,10 @@ def _serve(state): if event.completion_type != cygrpc.CompletionType.queue_timeout: if not _process_event_and_continue(state, event): return - # We want to force the deletion of the previous event - # ~before~ we poll again; if the event has a reference - # to a shutdown Call object, this can induce spinlock. - event = None + # We want to force the deletion of the previous event + # ~before~ we poll again; if the event has a reference + # to a shutdown Call object, this can induce spinlock. + event = None def _begin_shutdown_once(state): @@ -943,15 +943,15 @@ def _augment_options(base_options, compression): class _Server(grpc.Server): - # pylint: disable=too-many-arguments - def __init__(self, thread_pool, generic_handlers, interceptors, options, + # pylint: disable=too-many-arguments + def __init__(self, thread_pool, generic_handlers, interceptors, options, maximum_concurrent_rpcs, compression): completion_queue = cygrpc.CompletionQueue() server = cygrpc.Server(_augment_options(options, compression)) server.register_completion_queue(completion_queue) self._state = _ServerState(completion_queue, server, generic_handlers, - _interceptor.service_pipeline(interceptors), - thread_pool, maximum_concurrent_rpcs) + _interceptor.service_pipeline(interceptors), + thread_pool, maximum_concurrent_rpcs) def add_generic_rpc_handlers(self, generic_rpc_handlers): _validate_generic_rpc_handlers(generic_rpc_handlers) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/_utilities.py b/contrib/libs/grpc/src/python/grpcio/grpc/_utilities.py index c48aaf60a2..67789382d2 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/_utilities.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/_utilities.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Internal utilities for gRPC Python.""" import collections @@ -31,15 +31,15 @@ _DONE_CALLBACK_EXCEPTION_LOG_MESSAGE = ( class RpcMethodHandler( collections.namedtuple('_RpcMethodHandler', ( - 'request_streaming', - 'response_streaming', - 'request_deserializer', - 'response_serializer', - 'unary_unary', - 'unary_stream', - 'stream_unary', - 'stream_stream', - )), grpc.RpcMethodHandler): + 'request_streaming', + 'response_streaming', + 'request_deserializer', + 'response_serializer', + 'unary_unary', + 'unary_stream', + 'stream_unary', + 'stream_stream', + )), grpc.RpcMethodHandler): pass diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_client_adaptations.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_client_adaptations.py index 652ae0ea17..fb2925b413 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_client_adaptations.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_client_adaptations.py @@ -1,28 +1,28 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Translates gRPC's client-side API into gRPC's client-side Beta API.""" import grpc from grpc import _common -from grpc.beta import _metadata +from grpc.beta import _metadata from grpc.beta import interfaces from grpc.framework.common import cardinality from grpc.framework.foundation import future from grpc.framework.interfaces.face import face -# pylint: disable=too-many-arguments,too-many-locals,unused-argument - +# pylint: disable=too-many-arguments,too-many-locals,unused-argument + _STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASS = { grpc.StatusCode.CANCELLED: (face.Abortion.Kind.CANCELLED, face.CancellationError), @@ -51,7 +51,7 @@ def _abortion(rpc_error_call): code = rpc_error_call.code() pair = _STATUS_CODE_TO_ABORTION_KIND_AND_ABORTION_ERROR_CLASS.get(code) error_kind = face.Abortion.Kind.LOCAL_FAILURE if pair is None else pair[0] - return face.Abortion(error_kind, rpc_error_call.initial_metadata(), + return face.Abortion(error_kind, rpc_error_call.initial_metadata(), rpc_error_call.trailing_metadata(), code, rpc_error_call.details()) @@ -157,10 +157,10 @@ class _Rendezvous(future.Future, face.Call): return _InvocationProtocolContext() def initial_metadata(self): - return _metadata.beta(self._call.initial_metadata()) + return _metadata.beta(self._call.initial_metadata()) def terminal_metadata(self): - return _metadata.beta(self._call.terminal_metadata()) + return _metadata.beta(self._call.terminal_metadata()) def code(self): return self._call.code() @@ -182,7 +182,7 @@ def _blocking_unary_unary(channel, group, method, timeout, with_call, response, call = multi_callable.with_call( request, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return response, _Rendezvous(None, None, call) else: @@ -205,7 +205,7 @@ def _future_unary_unary(channel, group, method, timeout, protocol_options, response_future = multi_callable.future( request, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return _Rendezvous(response_future, None, response_future) @@ -221,7 +221,7 @@ def _unary_stream(channel, group, method, timeout, protocol_options, metadata, response_iterator = multi_callable( request, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return _Rendezvous(None, response_iterator, response_iterator) @@ -240,7 +240,7 @@ def _blocking_stream_unary(channel, group, method, timeout, with_call, response, call = multi_callable.with_call( request_iterator, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return response, _Rendezvous(None, None, call) else: @@ -263,7 +263,7 @@ def _future_stream_unary(channel, group, method, timeout, protocol_options, response_future = multi_callable.future( request_iterator, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return _Rendezvous(response_future, None, response_future) @@ -279,7 +279,7 @@ def _stream_stream(channel, group, method, timeout, protocol_options, metadata, response_iterator = multi_callable( request_iterator, timeout=timeout, - metadata=_metadata.unbeta(effective_metadata), + metadata=_metadata.unbeta(effective_metadata), credentials=_credentials(protocol_options)) return _Rendezvous(None, response_iterator, response_iterator) @@ -444,14 +444,14 @@ class _GenericStub(face.GenericStub): metadata=None, with_call=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _blocking_unary_unary(self._channel, group, method, timeout, with_call, protocol_options, metadata, self._metadata_transformer, request, @@ -464,14 +464,14 @@ class _GenericStub(face.GenericStub): timeout, metadata=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _future_unary_unary(self._channel, group, method, timeout, protocol_options, metadata, self._metadata_transformer, request, @@ -484,14 +484,14 @@ class _GenericStub(face.GenericStub): timeout, metadata=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _unary_stream(self._channel, group, method, timeout, protocol_options, metadata, self._metadata_transformer, request, @@ -505,14 +505,14 @@ class _GenericStub(face.GenericStub): metadata=None, with_call=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _blocking_stream_unary(self._channel, group, method, timeout, with_call, protocol_options, metadata, self._metadata_transformer, @@ -526,14 +526,14 @@ class _GenericStub(face.GenericStub): timeout, metadata=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _future_stream_unary(self._channel, group, method, timeout, protocol_options, metadata, self._metadata_transformer, @@ -547,14 +547,14 @@ class _GenericStub(face.GenericStub): timeout, metadata=None, protocol_options=None): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _stream_stream(self._channel, group, method, timeout, protocol_options, metadata, self._metadata_transformer, request_iterator, @@ -603,56 +603,56 @@ class _GenericStub(face.GenericStub): raise NotImplementedError() def unary_unary(self, group, method): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _UnaryUnaryMultiCallable(self._channel, group, method, self._metadata_transformer, request_serializer, response_deserializer) def unary_stream(self, group, method): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _UnaryStreamMultiCallable(self._channel, group, method, self._metadata_transformer, request_serializer, response_deserializer) def stream_unary(self, group, method): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _StreamUnaryMultiCallable(self._channel, group, method, self._metadata_transformer, request_serializer, response_deserializer) def stream_stream(self, group, method): - request_serializer = self._request_serializers.get(( - group, - method, - )) - response_deserializer = self._response_deserializers.get(( - group, - method, - )) + request_serializer = self._request_serializers.get(( + group, + method, + )) + response_deserializer = self._response_deserializers.get(( + group, + method, + )) return _StreamStreamMultiCallable(self._channel, group, method, self._metadata_transformer, request_serializer, @@ -667,8 +667,8 @@ class _GenericStub(face.GenericStub): class _DynamicStub(face.DynamicStub): - def __init__(self, backing_generic_stub, group, cardinalities): - self._generic_stub = backing_generic_stub + def __init__(self, backing_generic_stub, group, cardinalities): + self._generic_stub = backing_generic_stub self._group = group self._cardinalities = cardinalities diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_metadata.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_metadata.py index b7c8535285..bf94e628d6 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_metadata.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_metadata.py @@ -1,52 +1,52 @@ -# Copyright 2017 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""API metadata conversion utilities.""" - -import collections - -_Metadatum = collections.namedtuple('_Metadatum', ( - 'key', - 'value', -)) - - -def _beta_metadatum(key, value): - beta_key = key if isinstance(key, (bytes,)) else key.encode('ascii') - beta_value = value if isinstance(value, (bytes,)) else value.encode('ascii') - return _Metadatum(beta_key, beta_value) - - -def _metadatum(beta_key, beta_value): - key = beta_key if isinstance(beta_key, (str,)) else beta_key.decode('utf8') - if isinstance(beta_value, (str,)) or key[-4:] == '-bin': - value = beta_value - else: - value = beta_value.decode('utf8') - return _Metadatum(key, value) - - -def beta(metadata): - if metadata is None: - return () - else: - return tuple(_beta_metadatum(key, value) for key, value in metadata) - - -def unbeta(beta_metadata): - if beta_metadata is None: - return () - else: - return tuple( - _metadatum(beta_key, beta_value) - for beta_key, beta_value in beta_metadata) +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""API metadata conversion utilities.""" + +import collections + +_Metadatum = collections.namedtuple('_Metadatum', ( + 'key', + 'value', +)) + + +def _beta_metadatum(key, value): + beta_key = key if isinstance(key, (bytes,)) else key.encode('ascii') + beta_value = value if isinstance(value, (bytes,)) else value.encode('ascii') + return _Metadatum(beta_key, beta_value) + + +def _metadatum(beta_key, beta_value): + key = beta_key if isinstance(beta_key, (str,)) else beta_key.decode('utf8') + if isinstance(beta_value, (str,)) or key[-4:] == '-bin': + value = beta_value + else: + value = beta_value.decode('utf8') + return _Metadatum(key, value) + + +def beta(metadata): + if metadata is None: + return () + else: + return tuple(_beta_metadatum(key, value) for key, value in metadata) + + +def unbeta(beta_metadata): + if beta_metadata is None: + return () + else: + return tuple( + _metadatum(beta_key, beta_value) + for beta_key, beta_value in beta_metadata) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_server_adaptations.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_server_adaptations.py index 8843a3c550..2618ad896e 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/_server_adaptations.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/_server_adaptations.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Translates gRPC's server-side API into gRPC's server-side Beta API.""" import collections @@ -18,7 +18,7 @@ import threading import grpc from grpc import _common -from grpc.beta import _metadata +from grpc.beta import _metadata from grpc.beta import interfaces from grpc.framework.common import cardinality from grpc.framework.common import style @@ -27,8 +27,8 @@ from grpc.framework.foundation import logging_pool from grpc.framework.foundation import stream from grpc.framework.interfaces.face import face -# pylint: disable=too-many-return-statements - +# pylint: disable=too-many-return-statements + _DEFAULT_POOL_SIZE = 8 @@ -66,15 +66,15 @@ class _FaceServicerContext(face.ServicerContext): return _ServerProtocolContext(self._servicer_context) def invocation_metadata(self): - return _metadata.beta(self._servicer_context.invocation_metadata()) + return _metadata.beta(self._servicer_context.invocation_metadata()) def initial_metadata(self, initial_metadata): - self._servicer_context.send_initial_metadata( - _metadata.unbeta(initial_metadata)) + self._servicer_context.send_initial_metadata( + _metadata.unbeta(initial_metadata)) def terminal_metadata(self, terminal_metadata): - self._servicer_context.set_terminal_metadata( - _metadata.unbeta(terminal_metadata)) + self._servicer_context.set_terminal_metadata( + _metadata.unbeta(terminal_metadata)) def code(self, code): self._servicer_context.set_code(code) @@ -242,15 +242,15 @@ def _adapt_stream_stream_event(stream_stream_event): class _SimpleMethodHandler( collections.namedtuple('_MethodHandler', ( - 'request_streaming', - 'response_streaming', - 'request_deserializer', - 'response_serializer', - 'unary_unary', - 'unary_stream', - 'stream_unary', - 'stream_stream', - )), grpc.RpcMethodHandler): + 'request_streaming', + 'response_streaming', + 'request_deserializer', + 'response_serializer', + 'unary_unary', + 'unary_stream', + 'stream_unary', + 'stream_stream', + )), grpc.RpcMethodHandler): pass @@ -344,27 +344,27 @@ class _GenericRpcHandler(grpc.GenericRpcHandler): class _Server(interfaces.Server): - def __init__(self, grpc_server): - self._grpc_server = grpc_server + def __init__(self, grpc_server): + self._grpc_server = grpc_server def add_insecure_port(self, address): - return self._grpc_server.add_insecure_port(address) + return self._grpc_server.add_insecure_port(address) def add_secure_port(self, address, server_credentials): - return self._grpc_server.add_secure_port(address, server_credentials) + return self._grpc_server.add_secure_port(address, server_credentials) def start(self): - self._grpc_server.start() + self._grpc_server.start() def stop(self, grace): - return self._grpc_server.stop(grace) + return self._grpc_server.stop(grace) def __enter__(self): - self._grpc_server.start() + self._grpc_server.start() return self def __exit__(self, exc_type, exc_val, exc_tb): - self._grpc_server.stop(None) + self._grpc_server.stop(None) return False diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/implementations.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/implementations.py index c5507b543f..5be04202f0 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/implementations.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/implementations.py @@ -1,51 +1,51 @@ -# Copyright 2015-2016 gRPC authors. +# Copyright 2015-2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Entry points into the Beta API of gRPC Python.""" # threading is referenced from specification in this module. import threading # pylint: disable=unused-import -# interfaces, cardinality, and face are referenced from specification in this -# module. +# interfaces, cardinality, and face are referenced from specification in this +# module. import grpc from grpc import _auth from grpc.beta import _client_adaptations -from grpc.beta import _metadata +from grpc.beta import _metadata from grpc.beta import _server_adaptations -from grpc.beta import interfaces # pylint: disable=unused-import +from grpc.beta import interfaces # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.interfaces.face import face # pylint: disable=unused-import -# pylint: disable=too-many-arguments - +# pylint: disable=too-many-arguments + ChannelCredentials = grpc.ChannelCredentials ssl_channel_credentials = grpc.ssl_channel_credentials CallCredentials = grpc.CallCredentials -def metadata_call_credentials(metadata_plugin, name=None): - - def plugin(context, callback): - - def wrapped_callback(beta_metadata, error): - callback(_metadata.unbeta(beta_metadata), error) - - metadata_plugin(context, wrapped_callback) - - return grpc.metadata_call_credentials(plugin, name=name) - - +def metadata_call_credentials(metadata_plugin, name=None): + + def plugin(context, callback): + + def wrapped_callback(beta_metadata, error): + callback(_metadata.unbeta(beta_metadata), error) + + metadata_plugin(context, wrapped_callback) + + return grpc.metadata_call_credentials(plugin, name=name) + + def google_call_credentials(credentials): """Construct CallCredentials from GoogleCredentials. @@ -216,7 +216,7 @@ def dynamic_stub(channel, service, cardinalities, options=None): Returns: A face.DynamicStub with which RPCs can be invoked. """ - effective_options = _EMPTY_STUB_OPTIONS if options is None else options + effective_options = _EMPTY_STUB_OPTIONS if options is None else options return _client_adaptations.dynamic_stub( channel._channel, # pylint: disable=protected-access service, diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/interfaces.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/interfaces.py index fb8266c74b..28136a9840 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/interfaces.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/interfaces.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Constants and interfaces of the Beta API of gRPC Python.""" import abc diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/beta/utilities.py b/contrib/libs/grpc/src/python/grpcio/grpc/beta/utilities.py index fe3ce606c9..af88ddc925 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/beta/utilities.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/beta/utilities.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Utilities for the gRPC Python Beta API.""" import threading diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/experimental/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/experimental/__init__.py index a4e2660fb4..6140cad327 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/experimental/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/experimental/__init__.py @@ -1,20 +1,20 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""gRPC's experimental APIs. - -These APIs are subject to be removed during any minor version release. -""" +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""gRPC's experimental APIs. + +These APIs are subject to be removed during any minor version release. +""" import copy import functools diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/experimental/gevent.py b/contrib/libs/grpc/src/python/grpcio/grpc/experimental/gevent.py index 159d612b4e..998d05999f 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/experimental/gevent.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/experimental/gevent.py @@ -1,27 +1,27 @@ -# Copyright 2018 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""gRPC's Python gEvent APIs.""" - -from grpc._cython import cygrpc as _cygrpc - - -def init_gevent(): - """Patches gRPC's libraries to be compatible with gevent. - - This must be called AFTER the python standard lib has been patched, - but BEFORE creating and gRPC objects. - - In order for progress to be made, the application must drive the event loop. - """ - _cygrpc.init_grpc_gevent() +# Copyright 2018 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""gRPC's Python gEvent APIs.""" + +from grpc._cython import cygrpc as _cygrpc + + +def init_gevent(): + """Patches gRPC's libraries to be compatible with gevent. + + This must be called AFTER the python standard lib has been patched, + but BEFORE creating and gRPC objects. + + In order for progress to be made, the application must drive the event loop. + """ + _cygrpc.init_grpc_gevent() diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/cardinality.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/cardinality.py index c98735622d..0f7b6f0a94 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/cardinality.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/cardinality.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Defines an enum for classifying RPC methods by streaming semantics.""" import enum diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/style.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/style.py index f6138d417f..c051b27801 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/style.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/common/style.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Defines an enum for classifying RPC methods by control flow semantics.""" import enum diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/abandonment.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/abandonment.py index 660ce991c4..1c91cc39f0 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/abandonment.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/abandonment.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Utilities for indicating abandonment of computation.""" diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/callable_util.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/callable_util.py index 24daf3406f..f7f7ba3814 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/callable_util.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/callable_util.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Utilities for working with callables.""" import abc @@ -52,8 +52,8 @@ class _EasyOutcome( def _call_logging_exceptions(behavior, message, *args, **kwargs): try: - return _EasyOutcome(Outcome.Kind.RETURNED, behavior(*args, **kwargs), - None) + return _EasyOutcome(Outcome.Kind.RETURNED, behavior(*args, **kwargs), + None) except Exception as e: # pylint: disable=broad-except _LOGGER.exception(message) return _EasyOutcome(Outcome.Kind.RAISED, None, e) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/future.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/future.py index d11679cc3d..51fe7f67f7 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/future.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/future.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """A Future interface. Python doesn't have a Future interface in its standard library. In the absence diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/logging_pool.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/logging_pool.py index 421999fb1c..edfee343ca 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/logging_pool.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/logging_pool.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """A thread pool that logs exceptions raised by tasks executed within it.""" import logging @@ -26,7 +26,7 @@ def _wrap(behavior): def _wrapping(*args, **kwargs): try: return behavior(*args, **kwargs) - except Exception: + except Exception: _LOGGER.exception( 'Unexpected exception from %s executed in logging pool!', behavior) diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream.py index fd47977b89..86a5367086 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Interfaces related to streams of values or objects.""" import abc diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream_util.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream_util.py index 1faaf29bd7..a24c27f467 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream_util.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/foundation/stream_util.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Helpful utilities related to the stream module.""" import logging diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/base.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/base.py index 82c44f9110..80dd79d4ab 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/base.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/base.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """The base interface of RPC Framework. Implementations of this interface support the conduct of "operations": @@ -31,29 +31,29 @@ import six # abandonment is referenced from specification in this module. from grpc.framework.foundation import abandonment # pylint: disable=unused-import -# pylint: disable=too-many-arguments - +# pylint: disable=too-many-arguments + class NoSuchMethodError(Exception): """Indicates that an unrecognized operation has been called. - Attributes: + Attributes: code: A code value to communicate to the other side of the operation along with indication of operation termination. May be None. details: A details value to communicate to the other side of the operation along with indication of operation termination. May be None. """ - - def __init__(self, code, details): - """Constructor. - - Args: - code: A code value to communicate to the other side of the operation - along with indication of operation termination. May be None. - details: A details value to communicate to the other side of the - operation along with indication of operation termination. May be None. - """ - super(NoSuchMethodError, self).__init__() + + def __init__(self, code, details): + """Constructor. + + Args: + code: A code value to communicate to the other side of the operation + along with indication of operation termination. May be None. + details: A details value to communicate to the other side of the + operation along with indication of operation termination. May be None. + """ + super(NoSuchMethodError, self).__init__() self.code = code self.details = details diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/utilities.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/utilities.py index 281db62b5d..6e29a6d9bf 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/utilities.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/base/utilities.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Utilities for use with the base interface of RPC Framework.""" import collections @@ -19,22 +19,22 @@ from grpc.framework.interfaces.base import base class _Completion(base.Completion, - collections.namedtuple('_Completion', ( - 'terminal_metadata', - 'code', - 'message', - ))): + collections.namedtuple('_Completion', ( + 'terminal_metadata', + 'code', + 'message', + ))): """A trivial implementation of base.Completion.""" class _Subscription(base.Subscription, collections.namedtuple('_Subscription', ( - 'kind', - 'termination_callback', - 'allowance', - 'operator', - 'protocol_receiver', - ))): + 'kind', + 'termination_callback', + 'allowance', + 'operator', + 'protocol_receiver', + ))): """A trivial implementation of base.Subscription.""" diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/__init__.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/__init__.py index 5fb4f3c3cf..7de13e8c46 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/__init__.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/__init__.py @@ -1,13 +1,13 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/face.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/face.py index 5b47f11d0d..83f2abb93e 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/face.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/face.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Interfaces defining the Face layer of RPC Framework.""" import abc @@ -27,9 +27,9 @@ from grpc.framework.foundation import abandonment # pylint: disable=unused-impo from grpc.framework.foundation import future # pylint: disable=unused-import from grpc.framework.foundation import stream # pylint: disable=unused-import -# pylint: disable=too-many-arguments - +# pylint: disable=too-many-arguments + class NoSuchMethodError(Exception): """Raised by customer code to indicate an unrecognized method. @@ -50,20 +50,20 @@ class NoSuchMethodError(Exception): self.method = method def __repr__(self): - return 'face.NoSuchMethodError(%s, %s)' % ( - self.group, - self.method, - ) + return 'face.NoSuchMethodError(%s, %s)' % ( + self.group, + self.method, + ) class Abortion( - collections.namedtuple('Abortion', ( - 'kind', - 'initial_metadata', - 'terminal_metadata', - 'code', - 'details', - ))): + collections.namedtuple('Abortion', ( + 'kind', + 'initial_metadata', + 'terminal_metadata', + 'code', + 'details', + ))): """A value describing RPC abortion. Attributes: diff --git a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/utilities.py b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/utilities.py index f27bd67615..6e9832811d 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/utilities.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc/framework/interfaces/face/utilities.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Utilities for RPC Framework's Face interface.""" import collections diff --git a/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py b/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py index 67f985e1f4..ddd3422e92 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc_core_dependencies.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! @@ -236,148 +236,148 @@ CORE_SOURCE_FILES = [ 'src/core/lib/debug/stats.cc', 'src/core/lib/debug/stats_data.cc', 'src/core/lib/debug/trace.cc', - 'src/core/lib/gpr/alloc.cc', - 'src/core/lib/gpr/atm.cc', - 'src/core/lib/gpr/cpu_iphone.cc', - 'src/core/lib/gpr/cpu_linux.cc', - 'src/core/lib/gpr/cpu_posix.cc', - 'src/core/lib/gpr/cpu_windows.cc', - 'src/core/lib/gpr/env_linux.cc', - 'src/core/lib/gpr/env_posix.cc', - 'src/core/lib/gpr/env_windows.cc', - 'src/core/lib/gpr/log.cc', - 'src/core/lib/gpr/log_android.cc', - 'src/core/lib/gpr/log_linux.cc', - 'src/core/lib/gpr/log_posix.cc', - 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/murmur_hash.cc', - 'src/core/lib/gpr/string.cc', - 'src/core/lib/gpr/string_posix.cc', - 'src/core/lib/gpr/string_util_windows.cc', - 'src/core/lib/gpr/string_windows.cc', - 'src/core/lib/gpr/sync.cc', + 'src/core/lib/gpr/alloc.cc', + 'src/core/lib/gpr/atm.cc', + 'src/core/lib/gpr/cpu_iphone.cc', + 'src/core/lib/gpr/cpu_linux.cc', + 'src/core/lib/gpr/cpu_posix.cc', + 'src/core/lib/gpr/cpu_windows.cc', + 'src/core/lib/gpr/env_linux.cc', + 'src/core/lib/gpr/env_posix.cc', + 'src/core/lib/gpr/env_windows.cc', + 'src/core/lib/gpr/log.cc', + 'src/core/lib/gpr/log_android.cc', + 'src/core/lib/gpr/log_linux.cc', + 'src/core/lib/gpr/log_posix.cc', + 'src/core/lib/gpr/log_windows.cc', + 'src/core/lib/gpr/murmur_hash.cc', + 'src/core/lib/gpr/string.cc', + 'src/core/lib/gpr/string_posix.cc', + 'src/core/lib/gpr/string_util_windows.cc', + 'src/core/lib/gpr/string_windows.cc', + 'src/core/lib/gpr/sync.cc', 'src/core/lib/gpr/sync_abseil.cc', - 'src/core/lib/gpr/sync_posix.cc', - 'src/core/lib/gpr/sync_windows.cc', - 'src/core/lib/gpr/time.cc', - 'src/core/lib/gpr/time_posix.cc', - 'src/core/lib/gpr/time_precise.cc', - 'src/core/lib/gpr/time_windows.cc', - 'src/core/lib/gpr/tls_pthread.cc', - 'src/core/lib/gpr/tmpfile_msys.cc', - 'src/core/lib/gpr/tmpfile_posix.cc', - 'src/core/lib/gpr/tmpfile_windows.cc', - 'src/core/lib/gpr/wrap_memcpy.cc', + 'src/core/lib/gpr/sync_posix.cc', + 'src/core/lib/gpr/sync_windows.cc', + 'src/core/lib/gpr/time.cc', + 'src/core/lib/gpr/time_posix.cc', + 'src/core/lib/gpr/time_precise.cc', + 'src/core/lib/gpr/time_windows.cc', + 'src/core/lib/gpr/tls_pthread.cc', + 'src/core/lib/gpr/tmpfile_msys.cc', + 'src/core/lib/gpr/tmpfile_posix.cc', + 'src/core/lib/gpr/tmpfile_windows.cc', + 'src/core/lib/gpr/wrap_memcpy.cc', 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', 'src/core/lib/gprpp/host_port.cc', 'src/core/lib/gprpp/mpscq.cc', - 'src/core/lib/gprpp/thd_posix.cc', - 'src/core/lib/gprpp/thd_windows.cc', - 'src/core/lib/http/format_request.cc', - 'src/core/lib/http/httpcli.cc', + 'src/core/lib/gprpp/thd_posix.cc', + 'src/core/lib/gprpp/thd_windows.cc', + 'src/core/lib/http/format_request.cc', + 'src/core/lib/http/httpcli.cc', 'src/core/lib/http/httpcli_security_connector.cc', - 'src/core/lib/http/parser.cc', + 'src/core/lib/http/parser.cc', 'src/core/lib/iomgr/buffer_list.cc', - 'src/core/lib/iomgr/call_combiner.cc', + 'src/core/lib/iomgr/call_combiner.cc', 'src/core/lib/iomgr/cfstream_handle.cc', - 'src/core/lib/iomgr/combiner.cc', + 'src/core/lib/iomgr/combiner.cc', 'src/core/lib/iomgr/dualstack_socket_posix.cc', - 'src/core/lib/iomgr/endpoint.cc', + 'src/core/lib/iomgr/endpoint.cc', 'src/core/lib/iomgr/endpoint_cfstream.cc', - 'src/core/lib/iomgr/endpoint_pair_posix.cc', - 'src/core/lib/iomgr/endpoint_pair_uv.cc', - 'src/core/lib/iomgr/endpoint_pair_windows.cc', - 'src/core/lib/iomgr/error.cc', + 'src/core/lib/iomgr/endpoint_pair_posix.cc', + 'src/core/lib/iomgr/endpoint_pair_uv.cc', + 'src/core/lib/iomgr/endpoint_pair_windows.cc', + 'src/core/lib/iomgr/error.cc', 'src/core/lib/iomgr/error_cfstream.cc', 'src/core/lib/iomgr/ev_apple.cc', - 'src/core/lib/iomgr/ev_epoll1_linux.cc', - 'src/core/lib/iomgr/ev_epollex_linux.cc', - 'src/core/lib/iomgr/ev_poll_posix.cc', - 'src/core/lib/iomgr/ev_posix.cc', - 'src/core/lib/iomgr/ev_windows.cc', - 'src/core/lib/iomgr/exec_ctx.cc', - 'src/core/lib/iomgr/executor.cc', + 'src/core/lib/iomgr/ev_epoll1_linux.cc', + 'src/core/lib/iomgr/ev_epollex_linux.cc', + 'src/core/lib/iomgr/ev_poll_posix.cc', + 'src/core/lib/iomgr/ev_posix.cc', + 'src/core/lib/iomgr/ev_windows.cc', + 'src/core/lib/iomgr/exec_ctx.cc', + 'src/core/lib/iomgr/executor.cc', 'src/core/lib/iomgr/executor/mpmcqueue.cc', 'src/core/lib/iomgr/executor/threadpool.cc', - 'src/core/lib/iomgr/fork_posix.cc', - 'src/core/lib/iomgr/fork_windows.cc', - 'src/core/lib/iomgr/gethostname_fallback.cc', - 'src/core/lib/iomgr/gethostname_host_name_max.cc', - 'src/core/lib/iomgr/gethostname_sysconf.cc', + 'src/core/lib/iomgr/fork_posix.cc', + 'src/core/lib/iomgr/fork_windows.cc', + 'src/core/lib/iomgr/gethostname_fallback.cc', + 'src/core/lib/iomgr/gethostname_host_name_max.cc', + 'src/core/lib/iomgr/gethostname_sysconf.cc', 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc', 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc', 'src/core/lib/iomgr/internal_errqueue.cc', - 'src/core/lib/iomgr/iocp_windows.cc', - 'src/core/lib/iomgr/iomgr.cc', - 'src/core/lib/iomgr/iomgr_custom.cc', - 'src/core/lib/iomgr/iomgr_internal.cc', - 'src/core/lib/iomgr/iomgr_posix.cc', + 'src/core/lib/iomgr/iocp_windows.cc', + 'src/core/lib/iomgr/iomgr.cc', + 'src/core/lib/iomgr/iomgr_custom.cc', + 'src/core/lib/iomgr/iomgr_internal.cc', + 'src/core/lib/iomgr/iomgr_posix.cc', 'src/core/lib/iomgr/iomgr_posix_cfstream.cc', - 'src/core/lib/iomgr/iomgr_uv.cc', - 'src/core/lib/iomgr/iomgr_windows.cc', - 'src/core/lib/iomgr/is_epollexclusive_available.cc', - 'src/core/lib/iomgr/load_file.cc', - 'src/core/lib/iomgr/lockfree_event.cc', + 'src/core/lib/iomgr/iomgr_uv.cc', + 'src/core/lib/iomgr/iomgr_windows.cc', + 'src/core/lib/iomgr/is_epollexclusive_available.cc', + 'src/core/lib/iomgr/load_file.cc', + 'src/core/lib/iomgr/lockfree_event.cc', 'src/core/lib/iomgr/parse_address.cc', 'src/core/lib/iomgr/poller/eventmanager_libuv.cc', - 'src/core/lib/iomgr/polling_entity.cc', - 'src/core/lib/iomgr/pollset.cc', - 'src/core/lib/iomgr/pollset_custom.cc', - 'src/core/lib/iomgr/pollset_set.cc', - 'src/core/lib/iomgr/pollset_set_custom.cc', - 'src/core/lib/iomgr/pollset_set_windows.cc', - 'src/core/lib/iomgr/pollset_uv.cc', - 'src/core/lib/iomgr/pollset_windows.cc', - 'src/core/lib/iomgr/resolve_address.cc', - 'src/core/lib/iomgr/resolve_address_custom.cc', - 'src/core/lib/iomgr/resolve_address_posix.cc', - 'src/core/lib/iomgr/resolve_address_windows.cc', - 'src/core/lib/iomgr/resource_quota.cc', - 'src/core/lib/iomgr/sockaddr_utils.cc', - 'src/core/lib/iomgr/socket_factory_posix.cc', - 'src/core/lib/iomgr/socket_mutator.cc', - 'src/core/lib/iomgr/socket_utils_common_posix.cc', - 'src/core/lib/iomgr/socket_utils_linux.cc', - 'src/core/lib/iomgr/socket_utils_posix.cc', - 'src/core/lib/iomgr/socket_utils_uv.cc', - 'src/core/lib/iomgr/socket_utils_windows.cc', - 'src/core/lib/iomgr/socket_windows.cc', - 'src/core/lib/iomgr/tcp_client.cc', + 'src/core/lib/iomgr/polling_entity.cc', + 'src/core/lib/iomgr/pollset.cc', + 'src/core/lib/iomgr/pollset_custom.cc', + 'src/core/lib/iomgr/pollset_set.cc', + 'src/core/lib/iomgr/pollset_set_custom.cc', + 'src/core/lib/iomgr/pollset_set_windows.cc', + 'src/core/lib/iomgr/pollset_uv.cc', + 'src/core/lib/iomgr/pollset_windows.cc', + 'src/core/lib/iomgr/resolve_address.cc', + 'src/core/lib/iomgr/resolve_address_custom.cc', + 'src/core/lib/iomgr/resolve_address_posix.cc', + 'src/core/lib/iomgr/resolve_address_windows.cc', + 'src/core/lib/iomgr/resource_quota.cc', + 'src/core/lib/iomgr/sockaddr_utils.cc', + 'src/core/lib/iomgr/socket_factory_posix.cc', + 'src/core/lib/iomgr/socket_mutator.cc', + 'src/core/lib/iomgr/socket_utils_common_posix.cc', + 'src/core/lib/iomgr/socket_utils_linux.cc', + 'src/core/lib/iomgr/socket_utils_posix.cc', + 'src/core/lib/iomgr/socket_utils_uv.cc', + 'src/core/lib/iomgr/socket_utils_windows.cc', + 'src/core/lib/iomgr/socket_windows.cc', + 'src/core/lib/iomgr/tcp_client.cc', 'src/core/lib/iomgr/tcp_client_cfstream.cc', - 'src/core/lib/iomgr/tcp_client_custom.cc', - 'src/core/lib/iomgr/tcp_client_posix.cc', - 'src/core/lib/iomgr/tcp_client_windows.cc', - 'src/core/lib/iomgr/tcp_custom.cc', - 'src/core/lib/iomgr/tcp_posix.cc', - 'src/core/lib/iomgr/tcp_server.cc', - 'src/core/lib/iomgr/tcp_server_custom.cc', - 'src/core/lib/iomgr/tcp_server_posix.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc', - 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc', - 'src/core/lib/iomgr/tcp_server_windows.cc', - 'src/core/lib/iomgr/tcp_uv.cc', - 'src/core/lib/iomgr/tcp_windows.cc', - 'src/core/lib/iomgr/time_averaged_stats.cc', - 'src/core/lib/iomgr/timer.cc', - 'src/core/lib/iomgr/timer_custom.cc', - 'src/core/lib/iomgr/timer_generic.cc', - 'src/core/lib/iomgr/timer_heap.cc', - 'src/core/lib/iomgr/timer_manager.cc', - 'src/core/lib/iomgr/timer_uv.cc', - 'src/core/lib/iomgr/udp_server.cc', - 'src/core/lib/iomgr/unix_sockets_posix.cc', - 'src/core/lib/iomgr/unix_sockets_posix_noop.cc', - 'src/core/lib/iomgr/wakeup_fd_eventfd.cc', - 'src/core/lib/iomgr/wakeup_fd_nospecial.cc', - 'src/core/lib/iomgr/wakeup_fd_pipe.cc', - 'src/core/lib/iomgr/wakeup_fd_posix.cc', + 'src/core/lib/iomgr/tcp_client_custom.cc', + 'src/core/lib/iomgr/tcp_client_posix.cc', + 'src/core/lib/iomgr/tcp_client_windows.cc', + 'src/core/lib/iomgr/tcp_custom.cc', + 'src/core/lib/iomgr/tcp_posix.cc', + 'src/core/lib/iomgr/tcp_server.cc', + 'src/core/lib/iomgr/tcp_server_custom.cc', + 'src/core/lib/iomgr/tcp_server_posix.cc', + 'src/core/lib/iomgr/tcp_server_utils_posix_common.cc', + 'src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc', + 'src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc', + 'src/core/lib/iomgr/tcp_server_windows.cc', + 'src/core/lib/iomgr/tcp_uv.cc', + 'src/core/lib/iomgr/tcp_windows.cc', + 'src/core/lib/iomgr/time_averaged_stats.cc', + 'src/core/lib/iomgr/timer.cc', + 'src/core/lib/iomgr/timer_custom.cc', + 'src/core/lib/iomgr/timer_generic.cc', + 'src/core/lib/iomgr/timer_heap.cc', + 'src/core/lib/iomgr/timer_manager.cc', + 'src/core/lib/iomgr/timer_uv.cc', + 'src/core/lib/iomgr/udp_server.cc', + 'src/core/lib/iomgr/unix_sockets_posix.cc', + 'src/core/lib/iomgr/unix_sockets_posix_noop.cc', + 'src/core/lib/iomgr/wakeup_fd_eventfd.cc', + 'src/core/lib/iomgr/wakeup_fd_nospecial.cc', + 'src/core/lib/iomgr/wakeup_fd_pipe.cc', + 'src/core/lib/iomgr/wakeup_fd_posix.cc', 'src/core/lib/iomgr/work_serializer.cc', - 'src/core/lib/json/json_reader.cc', + 'src/core/lib/json/json_reader.cc', 'src/core/lib/json/json_util.cc', - 'src/core/lib/json/json_writer.cc', + 'src/core/lib/json/json_writer.cc', 'src/core/lib/profiling/basic_timers.cc', 'src/core/lib/profiling/stap_timers.cc', 'src/core/lib/security/authorization/authorization_engine.cc', @@ -425,75 +425,75 @@ CORE_SOURCE_FILES = [ 'src/core/lib/security/transport/server_auth_filter.cc', 'src/core/lib/security/transport/tsi_error.cc', 'src/core/lib/security/util/json_util.cc', - 'src/core/lib/slice/b64.cc', - 'src/core/lib/slice/percent_encoding.cc', - 'src/core/lib/slice/slice.cc', - 'src/core/lib/slice/slice_buffer.cc', - 'src/core/lib/slice/slice_intern.cc', - 'src/core/lib/slice/slice_string_helpers.cc', - 'src/core/lib/surface/api_trace.cc', - 'src/core/lib/surface/byte_buffer.cc', - 'src/core/lib/surface/byte_buffer_reader.cc', - 'src/core/lib/surface/call.cc', - 'src/core/lib/surface/call_details.cc', - 'src/core/lib/surface/call_log_batch.cc', - 'src/core/lib/surface/channel.cc', - 'src/core/lib/surface/channel_init.cc', - 'src/core/lib/surface/channel_ping.cc', - 'src/core/lib/surface/channel_stack_type.cc', - 'src/core/lib/surface/completion_queue.cc', - 'src/core/lib/surface/completion_queue_factory.cc', - 'src/core/lib/surface/event_string.cc', + 'src/core/lib/slice/b64.cc', + 'src/core/lib/slice/percent_encoding.cc', + 'src/core/lib/slice/slice.cc', + 'src/core/lib/slice/slice_buffer.cc', + 'src/core/lib/slice/slice_intern.cc', + 'src/core/lib/slice/slice_string_helpers.cc', + 'src/core/lib/surface/api_trace.cc', + 'src/core/lib/surface/byte_buffer.cc', + 'src/core/lib/surface/byte_buffer_reader.cc', + 'src/core/lib/surface/call.cc', + 'src/core/lib/surface/call_details.cc', + 'src/core/lib/surface/call_log_batch.cc', + 'src/core/lib/surface/channel.cc', + 'src/core/lib/surface/channel_init.cc', + 'src/core/lib/surface/channel_ping.cc', + 'src/core/lib/surface/channel_stack_type.cc', + 'src/core/lib/surface/completion_queue.cc', + 'src/core/lib/surface/completion_queue_factory.cc', + 'src/core/lib/surface/event_string.cc', 'src/core/lib/surface/init.cc', 'src/core/lib/surface/init_secure.cc', - 'src/core/lib/surface/lame_client.cc', - 'src/core/lib/surface/metadata_array.cc', - 'src/core/lib/surface/server.cc', - 'src/core/lib/surface/validate_metadata.cc', - 'src/core/lib/surface/version.cc', + 'src/core/lib/surface/lame_client.cc', + 'src/core/lib/surface/metadata_array.cc', + 'src/core/lib/surface/server.cc', + 'src/core/lib/surface/validate_metadata.cc', + 'src/core/lib/surface/version.cc', 'src/core/lib/transport/authority_override.cc', - 'src/core/lib/transport/bdp_estimator.cc', - 'src/core/lib/transport/byte_stream.cc', - 'src/core/lib/transport/connectivity_state.cc', - 'src/core/lib/transport/error_utils.cc', - 'src/core/lib/transport/metadata.cc', - 'src/core/lib/transport/metadata_batch.cc', - 'src/core/lib/transport/pid_controller.cc', - 'src/core/lib/transport/static_metadata.cc', - 'src/core/lib/transport/status_conversion.cc', - 'src/core/lib/transport/status_metadata.cc', - 'src/core/lib/transport/timeout_encoding.cc', - 'src/core/lib/transport/transport.cc', - 'src/core/lib/transport/transport_op_string.cc', + 'src/core/lib/transport/bdp_estimator.cc', + 'src/core/lib/transport/byte_stream.cc', + 'src/core/lib/transport/connectivity_state.cc', + 'src/core/lib/transport/error_utils.cc', + 'src/core/lib/transport/metadata.cc', + 'src/core/lib/transport/metadata_batch.cc', + 'src/core/lib/transport/pid_controller.cc', + 'src/core/lib/transport/static_metadata.cc', + 'src/core/lib/transport/status_conversion.cc', + 'src/core/lib/transport/status_metadata.cc', + 'src/core/lib/transport/timeout_encoding.cc', + 'src/core/lib/transport/transport.cc', + 'src/core/lib/transport/transport_op_string.cc', 'src/core/lib/uri/uri_parser.cc', 'src/core/plugin_registry/grpc_plugin_registry.cc', - 'src/core/tsi/alts/crypt/aes_gcm.cc', - 'src/core/tsi/alts/crypt/gsec.cc', - 'src/core/tsi/alts/frame_protector/alts_counter.cc', - 'src/core/tsi/alts/frame_protector/alts_crypter.cc', - 'src/core/tsi/alts/frame_protector/alts_frame_protector.cc', - 'src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc', - 'src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc', - 'src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc', - 'src/core/tsi/alts/frame_protector/frame_handler.cc', - 'src/core/tsi/alts/handshaker/alts_handshaker_client.cc', + 'src/core/tsi/alts/crypt/aes_gcm.cc', + 'src/core/tsi/alts/crypt/gsec.cc', + 'src/core/tsi/alts/frame_protector/alts_counter.cc', + 'src/core/tsi/alts/frame_protector/alts_crypter.cc', + 'src/core/tsi/alts/frame_protector/alts_frame_protector.cc', + 'src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.cc', + 'src/core/tsi/alts/frame_protector/alts_seal_privacy_integrity_crypter.cc', + 'src/core/tsi/alts/frame_protector/alts_unseal_privacy_integrity_crypter.cc', + 'src/core/tsi/alts/frame_protector/frame_handler.cc', + 'src/core/tsi/alts/handshaker/alts_handshaker_client.cc', 'src/core/tsi/alts/handshaker/alts_shared_resource.cc', - 'src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc', + 'src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc', 'src/core/tsi/alts/handshaker/alts_tsi_utils.cc', 'src/core/tsi/alts/handshaker/transport_security_common_api.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc', - 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc', - 'src/core/tsi/fake_transport_security.cc', + 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc', + 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.cc', + 'src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc', + 'src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc', + 'src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc', + 'src/core/tsi/fake_transport_security.cc', 'src/core/tsi/local_transport_security.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_cache.cc', - 'src/core/tsi/ssl/session_cache/ssl_session_openssl.cc', - 'src/core/tsi/ssl_transport_security.cc', + 'src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc', + 'src/core/tsi/ssl/session_cache/ssl_session_cache.cc', + 'src/core/tsi/ssl/session_cache/ssl_session_openssl.cc', + 'src/core/tsi/ssl_transport_security.cc', 'src/core/tsi/transport_security.cc', - 'src/core/tsi/transport_security_grpc.cc', + 'src/core/tsi/transport_security_grpc.cc', 'third_party/abseil-cpp/y_absl/base/dynamic_annotations.cc', 'third_party/abseil-cpp/y_absl/base/internal/cycleclock.cc', 'third_party/abseil-cpp/y_absl/base/internal/exponential_biased.cc', @@ -837,56 +837,56 @@ CORE_SOURCE_FILES = [ 'third_party/boringssl-with-bazel/src/ssl/tls13_server.cc', 'third_party/boringssl-with-bazel/src/ssl/tls_method.cc', 'third_party/boringssl-with-bazel/src/ssl/tls_record.cc', - 'third_party/cares/cares/ares__close_sockets.c', - 'third_party/cares/cares/ares__get_hostent.c', - 'third_party/cares/cares/ares__read_line.c', - 'third_party/cares/cares/ares__timeval.c', - 'third_party/cares/cares/ares_cancel.c', - 'third_party/cares/cares/ares_create_query.c', - 'third_party/cares/cares/ares_data.c', - 'third_party/cares/cares/ares_destroy.c', - 'third_party/cares/cares/ares_expand_name.c', - 'third_party/cares/cares/ares_expand_string.c', - 'third_party/cares/cares/ares_fds.c', - 'third_party/cares/cares/ares_free_hostent.c', - 'third_party/cares/cares/ares_free_string.c', - 'third_party/cares/cares/ares_getenv.c', - 'third_party/cares/cares/ares_gethostbyaddr.c', - 'third_party/cares/cares/ares_gethostbyname.c', - 'third_party/cares/cares/ares_getnameinfo.c', - 'third_party/cares/cares/ares_getopt.c', - 'third_party/cares/cares/ares_getsock.c', - 'third_party/cares/cares/ares_init.c', - 'third_party/cares/cares/ares_library_init.c', - 'third_party/cares/cares/ares_llist.c', - 'third_party/cares/cares/ares_mkquery.c', - 'third_party/cares/cares/ares_nowarn.c', - 'third_party/cares/cares/ares_options.c', - 'third_party/cares/cares/ares_parse_a_reply.c', - 'third_party/cares/cares/ares_parse_aaaa_reply.c', - 'third_party/cares/cares/ares_parse_mx_reply.c', - 'third_party/cares/cares/ares_parse_naptr_reply.c', - 'third_party/cares/cares/ares_parse_ns_reply.c', - 'third_party/cares/cares/ares_parse_ptr_reply.c', - 'third_party/cares/cares/ares_parse_soa_reply.c', - 'third_party/cares/cares/ares_parse_srv_reply.c', - 'third_party/cares/cares/ares_parse_txt_reply.c', - 'third_party/cares/cares/ares_platform.c', - 'third_party/cares/cares/ares_process.c', - 'third_party/cares/cares/ares_query.c', - 'third_party/cares/cares/ares_search.c', - 'third_party/cares/cares/ares_send.c', - 'third_party/cares/cares/ares_strcasecmp.c', - 'third_party/cares/cares/ares_strdup.c', - 'third_party/cares/cares/ares_strerror.c', + 'third_party/cares/cares/ares__close_sockets.c', + 'third_party/cares/cares/ares__get_hostent.c', + 'third_party/cares/cares/ares__read_line.c', + 'third_party/cares/cares/ares__timeval.c', + 'third_party/cares/cares/ares_cancel.c', + 'third_party/cares/cares/ares_create_query.c', + 'third_party/cares/cares/ares_data.c', + 'third_party/cares/cares/ares_destroy.c', + 'third_party/cares/cares/ares_expand_name.c', + 'third_party/cares/cares/ares_expand_string.c', + 'third_party/cares/cares/ares_fds.c', + 'third_party/cares/cares/ares_free_hostent.c', + 'third_party/cares/cares/ares_free_string.c', + 'third_party/cares/cares/ares_getenv.c', + 'third_party/cares/cares/ares_gethostbyaddr.c', + 'third_party/cares/cares/ares_gethostbyname.c', + 'third_party/cares/cares/ares_getnameinfo.c', + 'third_party/cares/cares/ares_getopt.c', + 'third_party/cares/cares/ares_getsock.c', + 'third_party/cares/cares/ares_init.c', + 'third_party/cares/cares/ares_library_init.c', + 'third_party/cares/cares/ares_llist.c', + 'third_party/cares/cares/ares_mkquery.c', + 'third_party/cares/cares/ares_nowarn.c', + 'third_party/cares/cares/ares_options.c', + 'third_party/cares/cares/ares_parse_a_reply.c', + 'third_party/cares/cares/ares_parse_aaaa_reply.c', + 'third_party/cares/cares/ares_parse_mx_reply.c', + 'third_party/cares/cares/ares_parse_naptr_reply.c', + 'third_party/cares/cares/ares_parse_ns_reply.c', + 'third_party/cares/cares/ares_parse_ptr_reply.c', + 'third_party/cares/cares/ares_parse_soa_reply.c', + 'third_party/cares/cares/ares_parse_srv_reply.c', + 'third_party/cares/cares/ares_parse_txt_reply.c', + 'third_party/cares/cares/ares_platform.c', + 'third_party/cares/cares/ares_process.c', + 'third_party/cares/cares/ares_query.c', + 'third_party/cares/cares/ares_search.c', + 'third_party/cares/cares/ares_send.c', + 'third_party/cares/cares/ares_strcasecmp.c', + 'third_party/cares/cares/ares_strdup.c', + 'third_party/cares/cares/ares_strerror.c', 'third_party/cares/cares/ares_strsplit.c', - 'third_party/cares/cares/ares_timeout.c', - 'third_party/cares/cares/ares_version.c', - 'third_party/cares/cares/ares_writev.c', - 'third_party/cares/cares/bitncmp.c', - 'third_party/cares/cares/inet_net_pton.c', - 'third_party/cares/cares/inet_ntop.c', - 'third_party/cares/cares/windows_port.c', + 'third_party/cares/cares/ares_timeout.c', + 'third_party/cares/cares/ares_version.c', + 'third_party/cares/cares/ares_writev.c', + 'third_party/cares/cares/bitncmp.c', + 'third_party/cares/cares/inet_net_pton.c', + 'third_party/cares/cares/inet_ntop.c', + 'third_party/cares/cares/windows_port.c', 'third_party/re2/re2/bitstate.cc', 'third_party/re2/re2/compile.cc', 'third_party/re2/re2/dfa.cc', diff --git a/contrib/libs/grpc/src/python/grpcio/grpc_version.py b/contrib/libs/grpc/src/python/grpcio/grpc_version.py index 9237f14e2f..34e666020e 100644 --- a/contrib/libs/grpc/src/python/grpcio/grpc_version.py +++ b/contrib/libs/grpc/src/python/grpcio/grpc_version.py @@ -1,16 +1,16 @@ -# Copyright 2015 gRPC authors. +# Copyright 2015 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! diff --git a/contrib/libs/grpc/src/python/grpcio/support.py b/contrib/libs/grpc/src/python/grpcio/support.py index 217f3cb9ed..1fe8209167 100644 --- a/contrib/libs/grpc/src/python/grpcio/support.py +++ b/contrib/libs/grpc/src/python/grpcio/support.py @@ -1,16 +1,16 @@ -# Copyright 2016 gRPC authors. +# Copyright 2016 gRPC authors. # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. import os import os.path @@ -101,7 +101,7 @@ def diagnose_attribute_error(build_ext, error): _ERROR_DIAGNOSES = { errors.CompileError: diagnose_compile_error, - AttributeError: diagnose_attribute_error, + AttributeError: diagnose_attribute_error, } @@ -109,10 +109,10 @@ def diagnose_build_ext_error(build_ext, error, formatted): diagnostic = _ERROR_DIAGNOSES.get(type(error)) if diagnostic is None: raise commands.CommandError( - "\n\nWe could not diagnose your build failure. If you are unable to " - "proceed, please file an issue at http://www.github.com/grpc/grpc " - "with `[Python install]` in the title; please attach the whole log " - "(including everything that may have appeared above the Python " - "backtrace).\n\n{}".format(formatted)) + "\n\nWe could not diagnose your build failure. If you are unable to " + "proceed, please file an issue at http://www.github.com/grpc/grpc " + "with `[Python install]` in the title; please attach the whole log " + "(including everything that may have appeared above the Python " + "backtrace).\n\n{}".format(formatted)) else: diagnostic(build_ext, error) diff --git a/contrib/libs/grpc/src/python/grpcio/ya.make b/contrib/libs/grpc/src/python/grpcio/ya.make index 5cdb0230c4..e0fb3ebbc1 100644 --- a/contrib/libs/grpc/src/python/grpcio/ya.make +++ b/contrib/libs/grpc/src/python/grpcio/ya.make @@ -22,63 +22,63 @@ IF (PYTHON2) ) ENDIF() -ADDINCL( +ADDINCL( ${ARCADIA_BUILD_ROOT}/contrib/libs/grpc - contrib/libs/grpc - contrib/libs/grpc/include -) + contrib/libs/grpc + contrib/libs/grpc/include +) IF (SANITIZER_TYPE == undefined) - # https://github.com/grpc/grpc/blob/v1.15.1/tools/bazel.rc#L43 - CXXFLAGS(-fno-sanitize=function) + # https://github.com/grpc/grpc/blob/v1.15.1/tools/bazel.rc#L43 + CXXFLAGS(-fno-sanitize=function) ENDIF() + +NO_LINT() -NO_LINT() - -NO_COMPILER_WARNINGS() +NO_COMPILER_WARNINGS() PY_SRCS( TOP_LEVEL - grpc/__init__.py + grpc/__init__.py grpc/_auth.py grpc/_channel.py grpc/_common.py grpc/_compression.py - grpc/_cython/__init__.py + grpc/_cython/__init__.py grpc/_cython/_cygrpc/__init__.py - grpc/_cython/cygrpc.pyx - grpc/_grpcio_metadata.py - grpc/_interceptor.py - grpc/_plugin_wrapping.py + grpc/_cython/cygrpc.pyx + grpc/_grpcio_metadata.py + grpc/_interceptor.py + grpc/_plugin_wrapping.py grpc/_runtime_protos.py - grpc/_server.py - grpc/_utilities.py - grpc/beta/__init__.py - grpc/beta/_client_adaptations.py - grpc/beta/_metadata.py - grpc/beta/_server_adaptations.py - grpc/beta/implementations.py - grpc/beta/interfaces.py - grpc/beta/utilities.py - grpc/experimental/__init__.py - grpc/experimental/gevent.py + grpc/_server.py + grpc/_utilities.py + grpc/beta/__init__.py + grpc/beta/_client_adaptations.py + grpc/beta/_metadata.py + grpc/beta/_server_adaptations.py + grpc/beta/implementations.py + grpc/beta/interfaces.py + grpc/beta/utilities.py + grpc/experimental/__init__.py + grpc/experimental/gevent.py grpc/experimental/session_cache.py - grpc/framework/__init__.py - grpc/framework/common/__init__.py + grpc/framework/__init__.py + grpc/framework/common/__init__.py grpc/framework/common/cardinality.py grpc/framework/common/style.py - grpc/framework/foundation/__init__.py + grpc/framework/foundation/__init__.py grpc/framework/foundation/abandonment.py grpc/framework/foundation/callable_util.py grpc/framework/foundation/future.py grpc/framework/foundation/logging_pool.py grpc/framework/foundation/stream.py grpc/framework/foundation/stream_util.py - grpc/framework/interfaces/__init__.py - grpc/framework/interfaces/base/__init__.py + grpc/framework/interfaces/__init__.py + grpc/framework/interfaces/base/__init__.py grpc/framework/interfaces/base/base.py grpc/framework/interfaces/base/utilities.py - grpc/framework/interfaces/face/__init__.py + grpc/framework/interfaces/face/__init__.py grpc/framework/interfaces/face/face.py grpc/framework/interfaces/face/utilities.py ) |