Functions | Variables
grpc._common Namespace Reference

Functions

def _transform (message, transformer, exception_message)
 
def _wait_once (wait_fn, timeout, spin_cb)
 
def decode (b)
 
def deserialize (serialized_message, deserializer)
 
def encode (s)
 
def fully_qualified_method (group, method)
 
def serialize (message, serializer)
 
def validate_port_binding_result (address, port)
 
def wait (wait_fn, wait_complete_fn, timeout=None, spin_cb=None)
 

Variables

string _ERROR_MESSAGE_PORT_BINDING_FAILED = 'Failed to bind to address %s; set ' \
 
 _LOGGER = logging.getLogger(__name__)
 
dictionary CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY
 
dictionary CYGRPC_STATUS_CODE_TO_STATUS_CODE
 
float MAXIMUM_WAIT_TIMEOUT = 0.1
 
dictionary STATUS_CODE_TO_CYGRPC_STATUS_CODE
 

Function Documentation

◆ _transform()

def grpc._common._transform (   message,
  transformer,
  exception_message 
)
private

Definition at line 81 of file grpc/_common.py.

◆ _wait_once()

def grpc._common._wait_once (   wait_fn,
  timeout,
  spin_cb 
)
private

Definition at line 105 of file grpc/_common.py.

◆ decode()

def grpc._common.decode (   b)

Definition at line 75 of file grpc/_common.py.

◆ deserialize()

def grpc._common.deserialize (   serialized_message,
  deserializer 
)

Definition at line 96 of file grpc/_common.py.

◆ encode()

def grpc._common.encode (   s)

Definition at line 68 of file grpc/_common.py.

◆ fully_qualified_method()

def grpc._common.fully_qualified_method (   group,
  method 
)

Definition at line 101 of file grpc/_common.py.

◆ serialize()

def grpc._common.serialize (   message,
  serializer 
)

Definition at line 92 of file grpc/_common.py.

◆ validate_port_binding_result()

def grpc._common.validate_port_binding_result (   address,
  port 
)
Validates if the port binding succeed.

If the port returned by Core is 0, the binding is failed. However, in that
case, the Core API doesn't return a detailed failing reason. The best we
can do is raising an exception to prevent further confusion.

Args:
    address: The address string to be bound.
    port: An int returned by core

Definition at line 152 of file grpc/_common.py.

◆ wait()

def grpc._common.wait (   wait_fn,
  wait_complete_fn,
  timeout = None,
  spin_cb = None 
)
Blocks waiting for an event without blocking the thread indefinitely.

See https://github.com/grpc/grpc/issues/19464 for full context. CPython's
`threading.Event.wait` and `threading.Condition.wait` methods, if invoked
without a timeout kwarg, may block the calling thread indefinitely. If the
call is made from the main thread, this means that signal handlers may not
run for an arbitrarily long period of time.

This wrapper calls the supplied wait function with an arbitrary short
timeout to ensure that no signal handler has to wait longer than
MAXIMUM_WAIT_TIMEOUT before executing.

Args:
  wait_fn: A callable acceptable a single float-valued kwarg named
    `timeout`. This function is expected to be one of `threading.Event.wait`
    or `threading.Condition.wait`.
  wait_complete_fn: A callable taking no arguments and returning a bool.
    When this function returns true, it indicates that waiting should cease.
  timeout: An optional float-valued number of seconds after which the wait
    should cease.
  spin_cb: An optional Callable taking no arguments and returning nothing.
    This callback will be called on each iteration of the spin. This may be
    used for, e.g. work related to forking.

Returns:
  True if a timeout was supplied and it was reached. False otherwise.

Definition at line 111 of file grpc/_common.py.

Variable Documentation

◆ _ERROR_MESSAGE_PORT_BINDING_FAILED

string grpc._common._ERROR_MESSAGE_PORT_BINDING_FAILED = 'Failed to bind to address %s; set ' \
private

Definition at line 64 of file grpc/_common.py.

◆ _LOGGER

grpc._common._LOGGER = logging.getLogger(__name__)
private

Definition at line 23 of file grpc/_common.py.

◆ CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY

dictionary grpc._common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY
Initial value:
1 = {
2  cygrpc.ConnectivityState.idle:
3  grpc.ChannelConnectivity.IDLE,
4  cygrpc.ConnectivityState.connecting:
5  grpc.ChannelConnectivity.CONNECTING,
6  cygrpc.ConnectivityState.ready:
7  grpc.ChannelConnectivity.READY,
8  cygrpc.ConnectivityState.transient_failure:
9  grpc.ChannelConnectivity.TRANSIENT_FAILURE,
10  cygrpc.ConnectivityState.shutdown:
11  grpc.ChannelConnectivity.SHUTDOWN,
12 }

Definition at line 25 of file grpc/_common.py.

◆ CYGRPC_STATUS_CODE_TO_STATUS_CODE

dictionary grpc._common.CYGRPC_STATUS_CODE_TO_STATUS_CODE
Initial value:
1 = {
2  cygrpc.StatusCode.ok: grpc.StatusCode.OK,
3  cygrpc.StatusCode.cancelled: grpc.StatusCode.CANCELLED,
4  cygrpc.StatusCode.unknown: grpc.StatusCode.UNKNOWN,
5  cygrpc.StatusCode.invalid_argument: grpc.StatusCode.INVALID_ARGUMENT,
6  cygrpc.StatusCode.deadline_exceeded: grpc.StatusCode.DEADLINE_EXCEEDED,
7  cygrpc.StatusCode.not_found: grpc.StatusCode.NOT_FOUND,
8  cygrpc.StatusCode.already_exists: grpc.StatusCode.ALREADY_EXISTS,
9  cygrpc.StatusCode.permission_denied: grpc.StatusCode.PERMISSION_DENIED,
10  cygrpc.StatusCode.unauthenticated: grpc.StatusCode.UNAUTHENTICATED,
11  cygrpc.StatusCode.resource_exhausted: grpc.StatusCode.RESOURCE_EXHAUSTED,
12  cygrpc.StatusCode.failed_precondition: grpc.StatusCode.FAILED_PRECONDITION,
13  cygrpc.StatusCode.aborted: grpc.StatusCode.ABORTED,
14  cygrpc.StatusCode.out_of_range: grpc.StatusCode.OUT_OF_RANGE,
15  cygrpc.StatusCode.unimplemented: grpc.StatusCode.UNIMPLEMENTED,
16  cygrpc.StatusCode.internal: grpc.StatusCode.INTERNAL,
17  cygrpc.StatusCode.unavailable: grpc.StatusCode.UNAVAILABLE,
18  cygrpc.StatusCode.data_loss: grpc.StatusCode.DATA_LOSS,
19 }

Definition at line 38 of file grpc/_common.py.

◆ MAXIMUM_WAIT_TIMEOUT

float grpc._common.MAXIMUM_WAIT_TIMEOUT = 0.1

Definition at line 62 of file grpc/_common.py.

◆ STATUS_CODE_TO_CYGRPC_STATUS_CODE

dictionary grpc._common.STATUS_CODE_TO_CYGRPC_STATUS_CODE
Initial value:
1 = {
2  grpc_code: cygrpc_code for cygrpc_code, grpc_code in six.iteritems(
3  CYGRPC_STATUS_CODE_TO_STATUS_CODE)
4 }

Definition at line 57 of file grpc/_common.py.



grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:31