@ -24,7 +24,6 @@ import types
from typing import (
Any ,
Callable ,
Dict ,
Iterator ,
List ,
Optional ,
@ -1055,7 +1054,6 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
_request_serializer : Optional [ SerializingFunction ]
_response_deserializer : Optional [ DeserializingFunction ]
_context : Any
_registered_call_handle : Optional [ int ]
__slots__ = [
" _channel " ,
@ -1076,7 +1074,6 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
target : bytes ,
request_serializer : Optional [ SerializingFunction ] ,
response_deserializer : Optional [ DeserializingFunction ] ,
_registered_call_handle : Optional [ int ] ,
) :
self . _channel = channel
self . _managed_call = managed_call
@ -1085,7 +1082,6 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
self . _request_serializer = request_serializer
self . _response_deserializer = response_deserializer
self . _context = cygrpc . build_census_context ( )
self . _registered_call_handle = _registered_call_handle
def _prepare (
self ,
@ -1157,7 +1153,6 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
) ,
) ,
self . _context ,
self . _registered_call_handle ,
)
event = call . next_event ( )
_handle_event ( event , state , self . _response_deserializer )
@ -1226,7 +1221,6 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable):
( operations , ) ,
event_handler ,
self . _context ,
self . _registered_call_handle ,
)
return _MultiThreadedRendezvous (
state , call , self . _response_deserializer , deadline
@ -1240,7 +1234,6 @@ class _SingleThreadedUnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
_request_serializer : Optional [ SerializingFunction ]
_response_deserializer : Optional [ DeserializingFunction ]
_context : Any
_registered_call_handle : Optional [ int ]
__slots__ = [
" _channel " ,
@ -1259,7 +1252,6 @@ class _SingleThreadedUnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
target : bytes ,
request_serializer : SerializingFunction ,
response_deserializer : DeserializingFunction ,
_registered_call_handle : Optional [ int ] ,
) :
self . _channel = channel
self . _method = method
@ -1267,7 +1259,6 @@ class _SingleThreadedUnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
self . _request_serializer = request_serializer
self . _response_deserializer = response_deserializer
self . _context = cygrpc . build_census_context ( )
self . _registered_call_handle = _registered_call_handle
def __call__ ( # pylint: disable=too-many-locals
self ,
@ -1326,7 +1317,6 @@ class _SingleThreadedUnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
call_credentials ,
operations_and_tags ,
self . _context ,
self . _registered_call_handle ,
)
return _SingleThreadedRendezvous (
state , call , self . _response_deserializer , deadline
@ -1341,7 +1331,6 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
_request_serializer : Optional [ SerializingFunction ]
_response_deserializer : Optional [ DeserializingFunction ]
_context : Any
_registered_call_handle : Optional [ int ]
__slots__ = [
" _channel " ,
@ -1362,7 +1351,6 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
target : bytes ,
request_serializer : SerializingFunction ,
response_deserializer : DeserializingFunction ,
_registered_call_handle : Optional [ int ] ,
) :
self . _channel = channel
self . _managed_call = managed_call
@ -1371,7 +1359,6 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
self . _request_serializer = request_serializer
self . _response_deserializer = response_deserializer
self . _context = cygrpc . build_census_context ( )
self . _registered_call_handle = _registered_call_handle
def __call__ ( # pylint: disable=too-many-locals
self ,
@ -1421,7 +1408,6 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable):
operations ,
_event_handler ( state , self . _response_deserializer ) ,
self . _context ,
self . _registered_call_handle ,
)
return _MultiThreadedRendezvous (
state , call , self . _response_deserializer , deadline
@ -1436,7 +1422,6 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
_request_serializer : Optional [ SerializingFunction ]
_response_deserializer : Optional [ DeserializingFunction ]
_context : Any
_registered_call_handle : Optional [ int ]
__slots__ = [
" _channel " ,
@ -1457,7 +1442,6 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
target : bytes ,
request_serializer : Optional [ SerializingFunction ] ,
response_deserializer : Optional [ DeserializingFunction ] ,
_registered_call_handle : Optional [ int ] ,
) :
self . _channel = channel
self . _managed_call = managed_call
@ -1466,7 +1450,6 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
self . _request_serializer = request_serializer
self . _response_deserializer = response_deserializer
self . _context = cygrpc . build_census_context ( )
self . _registered_call_handle = _registered_call_handle
def _blocking (
self ,
@ -1499,7 +1482,6 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
augmented_metadata , initial_metadata_flags
) ,
self . _context ,
self . _registered_call_handle ,
)
_consume_request_iterator (
request_iterator , state , call , self . _request_serializer , None
@ -1590,7 +1572,6 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable):
) ,
event_handler ,
self . _context ,
self . _registered_call_handle ,
)
_consume_request_iterator (
request_iterator ,
@ -1612,7 +1593,6 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
_request_serializer : Optional [ SerializingFunction ]
_response_deserializer : Optional [ DeserializingFunction ]
_context : Any
_registered_call_handle : Optional [ int ]
__slots__ = [
" _channel " ,
@ -1631,9 +1611,8 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
managed_call : IntegratedCallFactory ,
method : bytes ,
target : bytes ,
request_serializer : Optional [ SerializingFunction ] ,
response_deserializer : Optional [ DeserializingFunction ] ,
_registered_call_handle : Optional [ int ] ,
request_serializer : Optional [ SerializingFunction ] = None ,
response_deserializer : Optional [ DeserializingFunction ] = None ,
) :
self . _channel = channel
self . _managed_call = managed_call
@ -1642,7 +1621,6 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
self . _request_serializer = request_serializer
self . _response_deserializer = response_deserializer
self . _context = cygrpc . build_census_context ( )
self . _registered_call_handle = _registered_call_handle
def __call__ (
self ,
@ -1684,7 +1662,6 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable):
operations ,
event_handler ,
self . _context ,
self . _registered_call_handle ,
)
_consume_request_iterator (
request_iterator ,
@ -1774,8 +1751,7 @@ def _channel_managed_call_management(state: _ChannelCallState):
credentials : Optional [ cygrpc . CallCredentials ] ,
operations : Sequence [ Sequence [ cygrpc . Operation ] ] ,
event_handler : UserTag ,
context : Any ,
_registered_call_handle : Optional [ int ] ,
context ,
) - > cygrpc . IntegratedCall :
""" Creates a cygrpc.IntegratedCall.
@ -1792,8 +1768,6 @@ def _channel_managed_call_management(state: _ChannelCallState):
event_handler : A behavior to call to handle the events resultant from
the operations on the call .
context : Context object for distributed tracing .
_registered_call_handle : An int representing the call handle of the
method , or None if the method is not registered .
Returns :
A cygrpc . IntegratedCall with which to conduct an RPC .
"""
@ -1814,7 +1788,6 @@ def _channel_managed_call_management(state: _ChannelCallState):
credentials ,
operations_and_tags ,
context ,
_registered_call_handle ,
)
if state . managed_calls == 0 :
state . managed_calls = 1
@ -2048,7 +2021,6 @@ class Channel(grpc.Channel):
_call_state : _ChannelCallState
_connectivity_state : _ChannelConnectivityState
_target : str
_registered_call_handles : Dict [ str , int ]
def __init__ (
self ,
@ -2083,22 +2055,6 @@ class Channel(grpc.Channel):
if cygrpc . g_gevent_activated :
cygrpc . gevent_increment_channel_count ( )
def _get_registered_call_handle ( self , method : str ) - > int :
"""
Get the registered call handle for a method .
This is a semi - private method . It is intended for use only by gRPC generated code .
This method is not thread - safe .
Args :
method : Required , the method name for the RPC .
Returns :
The registered call handle pointer in the form of a Python Long .
"""
return self . _channel . get_registered_call_handle ( _common . encode ( method ) )
def _process_python_options (
self , python_options : Sequence [ ChannelArgumentType ]
) - > None :
@ -2122,17 +2078,12 @@ class Channel(grpc.Channel):
) - > None :
_unsubscribe ( self . _connectivity_state , callback )
# pylint: disable=arguments-differ
def unary_unary (
self ,
method : str ,
request_serializer : Optional [ SerializingFunction ] = None ,
response_deserializer : Optional [ DeserializingFunction ] = None ,
_registered_method : Optional [ bool ] = False ,
) - > grpc . UnaryUnaryMultiCallable :
_registered_call_handle = None
if _registered_method :
_registered_call_handle = self . _get_registered_call_handle ( method )
return _UnaryUnaryMultiCallable (
self . _channel ,
_channel_managed_call_management ( self . _call_state ) ,
@ -2140,20 +2091,14 @@ class Channel(grpc.Channel):
_common . encode ( self . _target ) ,
request_serializer ,
response_deserializer ,
_registered_call_handle ,
)
# pylint: disable=arguments-differ
def unary_stream (
self ,
method : str ,
request_serializer : Optional [ SerializingFunction ] = None ,
response_deserializer : Optional [ DeserializingFunction ] = None ,
_registered_method : Optional [ bool ] = False ,
) - > grpc . UnaryStreamMultiCallable :
_registered_call_handle = None
if _registered_method :
_registered_call_handle = self . _get_registered_call_handle ( method )
# NOTE(rbellevi): Benchmarks have shown that running a unary-stream RPC
# on a single Python thread results in an appreciable speed-up. However,
# due to slight differences in capability, the multi-threaded variant
@ -2165,7 +2110,6 @@ class Channel(grpc.Channel):
_common . encode ( self . _target ) ,
request_serializer ,
response_deserializer ,
_registered_call_handle ,
)
else :
return _UnaryStreamMultiCallable (
@ -2175,20 +2119,14 @@ class Channel(grpc.Channel):
_common . encode ( self . _target ) ,
request_serializer ,
response_deserializer ,
_registered_call_handle ,
)
# pylint: disable=arguments-differ
def stream_unary (
self ,
method : str ,
request_serializer : Optional [ SerializingFunction ] = None ,
response_deserializer : Optional [ DeserializingFunction ] = None ,
_registered_method : Optional [ bool ] = False ,
) - > grpc . StreamUnaryMultiCallable :
_registered_call_handle = None
if _registered_method :
_registered_call_handle = self . _get_registered_call_handle ( method )
return _StreamUnaryMultiCallable (
self . _channel ,
_channel_managed_call_management ( self . _call_state ) ,
@ -2196,20 +2134,14 @@ class Channel(grpc.Channel):
_common . encode ( self . _target ) ,
request_serializer ,
response_deserializer ,
_registered_call_handle ,
)
# pylint: disable=arguments-differ
def stream_stream (
self ,
method : str ,
request_serializer : Optional [ SerializingFunction ] = None ,
response_deserializer : Optional [ DeserializingFunction ] = None ,
_registered_method : Optional [ bool ] = False ,
) - > grpc . StreamStreamMultiCallable :
_registered_call_handle = None
if _registered_method :
_registered_call_handle = self . _get_registered_call_handle ( method )
return _StreamStreamMultiCallable (
self . _channel ,
_channel_managed_call_management ( self . _call_state ) ,
@ -2217,7 +2149,6 @@ class Channel(grpc.Channel):
_common . encode ( self . _target ) ,
request_serializer ,
response_deserializer ,
_registered_call_handle ,
)
def _unsubscribe_all ( self ) - > None :