|
|
@ -26,7 +26,6 @@ |
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
|
|
|
|
|
|
|
|
"""Invocation-side implementation of gRPC Python.""" |
|
|
|
"""Invocation-side implementation of gRPC Python.""" |
|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
|
import sys |
|
|
@ -52,26 +51,22 @@ _UNARY_UNARY_INITIAL_DUE = ( |
|
|
|
cygrpc.OperationType.send_close_from_client, |
|
|
|
cygrpc.OperationType.send_close_from_client, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_message, |
|
|
|
cygrpc.OperationType.receive_message, |
|
|
|
cygrpc.OperationType.receive_status_on_client, |
|
|
|
cygrpc.OperationType.receive_status_on_client,) |
|
|
|
) |
|
|
|
|
|
|
|
_UNARY_STREAM_INITIAL_DUE = ( |
|
|
|
_UNARY_STREAM_INITIAL_DUE = ( |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.send_message, |
|
|
|
cygrpc.OperationType.send_message, |
|
|
|
cygrpc.OperationType.send_close_from_client, |
|
|
|
cygrpc.OperationType.send_close_from_client, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_status_on_client, |
|
|
|
cygrpc.OperationType.receive_status_on_client,) |
|
|
|
) |
|
|
|
|
|
|
|
_STREAM_UNARY_INITIAL_DUE = ( |
|
|
|
_STREAM_UNARY_INITIAL_DUE = ( |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_message, |
|
|
|
cygrpc.OperationType.receive_message, |
|
|
|
cygrpc.OperationType.receive_status_on_client, |
|
|
|
cygrpc.OperationType.receive_status_on_client,) |
|
|
|
) |
|
|
|
|
|
|
|
_STREAM_STREAM_INITIAL_DUE = ( |
|
|
|
_STREAM_STREAM_INITIAL_DUE = ( |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.send_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_initial_metadata, |
|
|
|
cygrpc.OperationType.receive_status_on_client, |
|
|
|
cygrpc.OperationType.receive_status_on_client,) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE = ( |
|
|
|
_CHANNEL_SUBSCRIPTION_CALLBACK_ERROR_LOG_MESSAGE = ( |
|
|
|
'Exception calling channel subscription callback!') |
|
|
|
'Exception calling channel subscription callback!') |
|
|
@ -100,23 +95,28 @@ def _wait_once_until(condition, until): |
|
|
|
else: |
|
|
|
else: |
|
|
|
condition.wait(timeout=remaining) |
|
|
|
condition.wait(timeout=remaining) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_INTERNAL_CALL_ERROR_MESSAGE_FORMAT = ( |
|
|
|
_INTERNAL_CALL_ERROR_MESSAGE_FORMAT = ( |
|
|
|
'Internal gRPC call error %d. ' + |
|
|
|
'Internal gRPC call error %d. ' + |
|
|
|
'Please report to https://github.com/grpc/grpc/issues') |
|
|
|
'Please report to https://github.com/grpc/grpc/issues') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _check_call_error(call_error, metadata): |
|
|
|
def _check_call_error(call_error, metadata): |
|
|
|
if call_error == cygrpc.CallError.invalid_metadata: |
|
|
|
if call_error == cygrpc.CallError.invalid_metadata: |
|
|
|
raise ValueError('metadata was invalid: %s' % metadata) |
|
|
|
raise ValueError('metadata was invalid: %s' % metadata) |
|
|
|
elif call_error != cygrpc.CallError.ok: |
|
|
|
elif call_error != cygrpc.CallError.ok: |
|
|
|
raise ValueError(_INTERNAL_CALL_ERROR_MESSAGE_FORMAT % call_error) |
|
|
|
raise ValueError(_INTERNAL_CALL_ERROR_MESSAGE_FORMAT % call_error) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _call_error_set_RPCstate(state, call_error, metadata): |
|
|
|
def _call_error_set_RPCstate(state, call_error, metadata): |
|
|
|
if call_error == cygrpc.CallError.invalid_metadata: |
|
|
|
if call_error == cygrpc.CallError.invalid_metadata: |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, 'metadata was invalid: %s' % metadata) |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, |
|
|
|
|
|
|
|
'metadata was invalid: %s' % metadata) |
|
|
|
else: |
|
|
|
else: |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, |
|
|
|
_INTERNAL_CALL_ERROR_MESSAGE_FORMAT % call_error) |
|
|
|
_INTERNAL_CALL_ERROR_MESSAGE_FORMAT % call_error) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _RPCState(object): |
|
|
|
class _RPCState(object): |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, due, initial_metadata, trailing_metadata, code, details): |
|
|
|
def __init__(self, due, initial_metadata, trailing_metadata, code, details): |
|
|
@ -156,8 +156,8 @@ def _handle_event(event, state, response_deserializer): |
|
|
|
elif operation_type == cygrpc.OperationType.receive_message: |
|
|
|
elif operation_type == cygrpc.OperationType.receive_message: |
|
|
|
serialized_response = batch_operation.received_message.bytes() |
|
|
|
serialized_response = batch_operation.received_message.bytes() |
|
|
|
if serialized_response is not None: |
|
|
|
if serialized_response is not None: |
|
|
|
response = _common.deserialize( |
|
|
|
response = _common.deserialize(serialized_response, |
|
|
|
serialized_response, response_deserializer) |
|
|
|
response_deserializer) |
|
|
|
if response is None: |
|
|
|
if response is None: |
|
|
|
details = 'Exception deserializing response!' |
|
|
|
details = 'Exception deserializing response!' |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, details) |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, details) |
|
|
@ -182,6 +182,7 @@ def _handle_event(event, state, response_deserializer): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _event_handler(state, call, response_deserializer): |
|
|
|
def _event_handler(state, call, response_deserializer): |
|
|
|
|
|
|
|
|
|
|
|
def handle_event(event): |
|
|
|
def handle_event(event): |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
callbacks = _handle_event(event, state, response_deserializer) |
|
|
|
callbacks = _handle_event(event, state, response_deserializer) |
|
|
@ -190,11 +191,12 @@ def _event_handler(state, call, response_deserializer): |
|
|
|
for callback in callbacks: |
|
|
|
for callback in callbacks: |
|
|
|
callback() |
|
|
|
callback() |
|
|
|
return call if done else None |
|
|
|
return call if done else None |
|
|
|
|
|
|
|
|
|
|
|
return handle_event |
|
|
|
return handle_event |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _consume_request_iterator( |
|
|
|
def _consume_request_iterator(request_iterator, state, call, |
|
|
|
request_iterator, state, call, request_serializer): |
|
|
|
request_serializer): |
|
|
|
event_handler = _event_handler(state, call, None) |
|
|
|
event_handler = _event_handler(state, call, None) |
|
|
|
|
|
|
|
|
|
|
|
def consume_request_iterator(): |
|
|
|
def consume_request_iterator(): |
|
|
@ -206,7 +208,8 @@ def _consume_request_iterator( |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
logging.exception("Exception iterating requests!") |
|
|
|
logging.exception("Exception iterating requests!") |
|
|
|
call.cancel() |
|
|
|
call.cancel() |
|
|
|
_abort(state, grpc.StatusCode.UNKNOWN, "Exception iterating requests!") |
|
|
|
_abort(state, grpc.StatusCode.UNKNOWN, |
|
|
|
|
|
|
|
"Exception iterating requests!") |
|
|
|
return |
|
|
|
return |
|
|
|
serialized_request = _common.serialize(request, request_serializer) |
|
|
|
serialized_request = _common.serialize(request, request_serializer) |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
@ -217,12 +220,10 @@ def _consume_request_iterator( |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, details) |
|
|
|
_abort(state, grpc.StatusCode.INTERNAL, details) |
|
|
|
return |
|
|
|
return |
|
|
|
else: |
|
|
|
else: |
|
|
|
operations = ( |
|
|
|
operations = (cygrpc.operation_send_message( |
|
|
|
cygrpc.operation_send_message( |
|
|
|
serialized_request, _EMPTY_FLAGS),) |
|
|
|
serialized_request, _EMPTY_FLAGS), |
|
|
|
call.start_client_batch( |
|
|
|
) |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
call.start_client_batch(cygrpc.Operations(operations), |
|
|
|
|
|
|
|
event_handler) |
|
|
|
|
|
|
|
state.due.add(cygrpc.OperationType.send_message) |
|
|
|
state.due.add(cygrpc.OperationType.send_message) |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
state.condition.wait() |
|
|
|
state.condition.wait() |
|
|
@ -236,9 +237,9 @@ def _consume_request_iterator( |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
if state.code is None: |
|
|
|
if state.code is None: |
|
|
|
operations = ( |
|
|
|
operations = ( |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
call.start_client_batch( |
|
|
|
call.start_client_batch(cygrpc.Operations(operations), event_handler) |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
state.due.add(cygrpc.OperationType.send_close_from_client) |
|
|
|
state.due.add(cygrpc.OperationType.send_close_from_client) |
|
|
|
|
|
|
|
|
|
|
|
def stop_consumption_thread(timeout): |
|
|
|
def stop_consumption_thread(timeout): |
|
|
@ -337,8 +338,8 @@ class _Rendezvous(grpc.RpcError, grpc.Future, grpc.Call): |
|
|
|
def _next(self): |
|
|
|
def _next(self): |
|
|
|
with self._state.condition: |
|
|
|
with self._state.condition: |
|
|
|
if self._state.code is None: |
|
|
|
if self._state.code is None: |
|
|
|
event_handler = _event_handler( |
|
|
|
event_handler = _event_handler(self._state, self._call, |
|
|
|
self._state, self._call, self._response_deserializer) |
|
|
|
self._response_deserializer) |
|
|
|
self._call.start_client_batch( |
|
|
|
self._call.start_client_batch( |
|
|
|
cygrpc.Operations( |
|
|
|
cygrpc.Operations( |
|
|
|
(cygrpc.operation_receive_message(_EMPTY_FLAGS),)), |
|
|
|
(cygrpc.operation_receive_message(_EMPTY_FLAGS),)), |
|
|
@ -438,8 +439,8 @@ def _start_unary_request(request, timeout, request_serializer): |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
serialized_request = _common.serialize(request, request_serializer) |
|
|
|
serialized_request = _common.serialize(request, request_serializer) |
|
|
|
if serialized_request is None: |
|
|
|
if serialized_request is None: |
|
|
|
state = _RPCState( |
|
|
|
state = _RPCState((), _EMPTY_METADATA, _EMPTY_METADATA, |
|
|
|
(), _EMPTY_METADATA, _EMPTY_METADATA, grpc.StatusCode.INTERNAL, |
|
|
|
grpc.StatusCode.INTERNAL, |
|
|
|
'Exception serializing request!') |
|
|
|
'Exception serializing request!') |
|
|
|
rendezvous = _Rendezvous(state, None, None, deadline) |
|
|
|
rendezvous = _Rendezvous(state, None, None, deadline) |
|
|
|
return deadline, deadline_timespec, None, rendezvous |
|
|
|
return deadline, deadline_timespec, None, rendezvous |
|
|
@ -460,8 +461,7 @@ def _end_unary_response_blocking(state, with_call, deadline): |
|
|
|
|
|
|
|
|
|
|
|
class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): |
|
|
|
class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): |
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
|
def __init__(self, channel, managed_call, method, request_serializer, |
|
|
|
self, channel, managed_call, method, request_serializer, |
|
|
|
|
|
|
|
response_deserializer): |
|
|
|
response_deserializer): |
|
|
|
self._channel = channel |
|
|
|
self._channel = channel |
|
|
|
self._managed_call = managed_call |
|
|
|
self._managed_call = managed_call |
|
|
@ -483,8 +483,7 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
|
|
|
|
return state, operations, deadline, deadline_timespec, None |
|
|
|
return state, operations, deadline, deadline_timespec, None |
|
|
|
|
|
|
|
|
|
|
|
def _blocking(self, request, timeout, metadata, credentials): |
|
|
|
def _blocking(self, request, timeout, metadata, credentials): |
|
|
@ -494,21 +493,26 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): |
|
|
|
raise rendezvous |
|
|
|
raise rendezvous |
|
|
|
else: |
|
|
|
else: |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
call = self._channel.create_call( |
|
|
|
call = self._channel.create_call(None, 0, completion_queue, |
|
|
|
None, 0, completion_queue, self._method, None, deadline_timespec) |
|
|
|
self._method, None, |
|
|
|
|
|
|
|
deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), None) |
|
|
|
call_error = call.start_client_batch( |
|
|
|
|
|
|
|
cygrpc.Operations(operations), None) |
|
|
|
_check_call_error(call_error, metadata) |
|
|
|
_check_call_error(call_error, metadata) |
|
|
|
_handle_event(completion_queue.poll(), state, self._response_deserializer) |
|
|
|
_handle_event(completion_queue.poll(), state, |
|
|
|
|
|
|
|
self._response_deserializer) |
|
|
|
return state, deadline |
|
|
|
return state, deadline |
|
|
|
|
|
|
|
|
|
|
|
def __call__(self, request, timeout=None, metadata=None, credentials=None): |
|
|
|
def __call__(self, request, timeout=None, metadata=None, credentials=None): |
|
|
|
state, deadline, = self._blocking(request, timeout, metadata, credentials) |
|
|
|
state, deadline, = self._blocking(request, timeout, metadata, |
|
|
|
|
|
|
|
credentials) |
|
|
|
return _end_unary_response_blocking(state, False, deadline) |
|
|
|
return _end_unary_response_blocking(state, False, deadline) |
|
|
|
|
|
|
|
|
|
|
|
def with_call(self, request, timeout=None, metadata=None, credentials=None): |
|
|
|
def with_call(self, request, timeout=None, metadata=None, credentials=None): |
|
|
|
state, deadline, = self._blocking(request, timeout, metadata, credentials) |
|
|
|
state, deadline, = self._blocking(request, timeout, metadata, |
|
|
|
|
|
|
|
credentials) |
|
|
|
return _end_unary_response_blocking(state, True, deadline) |
|
|
|
return _end_unary_response_blocking(state, True, deadline) |
|
|
|
|
|
|
|
|
|
|
|
def future(self, request, timeout=None, metadata=None, credentials=None): |
|
|
|
def future(self, request, timeout=None, metadata=None, credentials=None): |
|
|
@ -517,25 +521,26 @@ class _UnaryUnaryMultiCallable(grpc.UnaryUnaryMultiCallable): |
|
|
|
if rendezvous: |
|
|
|
if rendezvous: |
|
|
|
return rendezvous |
|
|
|
return rendezvous |
|
|
|
else: |
|
|
|
else: |
|
|
|
call, drive_call = self._managed_call( |
|
|
|
call, drive_call = self._managed_call(None, 0, self._method, None, |
|
|
|
None, 0, self._method, None, deadline_timespec) |
|
|
|
deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
|
event_handler = _event_handler(state, call, |
|
|
|
|
|
|
|
self._response_deserializer) |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), |
|
|
|
call_error = call.start_client_batch( |
|
|
|
event_handler) |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
drive_call() |
|
|
|
drive_call() |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, |
|
|
|
|
|
|
|
deadline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): |
|
|
|
class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): |
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
|
def __init__(self, channel, managed_call, method, request_serializer, |
|
|
|
self, channel, managed_call, method, request_serializer, |
|
|
|
|
|
|
|
response_deserializer): |
|
|
|
response_deserializer): |
|
|
|
self._channel = channel |
|
|
|
self._channel = channel |
|
|
|
self._managed_call = managed_call |
|
|
|
self._managed_call = managed_call |
|
|
@ -550,36 +555,37 @@ class _UnaryStreamMultiCallable(grpc.UnaryStreamMultiCallable): |
|
|
|
raise rendezvous |
|
|
|
raise rendezvous |
|
|
|
else: |
|
|
|
else: |
|
|
|
state = _RPCState(_UNARY_STREAM_INITIAL_DUE, None, None, None, None) |
|
|
|
state = _RPCState(_UNARY_STREAM_INITIAL_DUE, None, None, None, None) |
|
|
|
call, drive_call = self._managed_call( |
|
|
|
call, drive_call = self._managed_call(None, 0, self._method, None, |
|
|
|
None, 0, self._method, None, deadline_timespec) |
|
|
|
deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
|
event_handler = _event_handler(state, call, |
|
|
|
|
|
|
|
self._response_deserializer) |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
|
call.start_client_batch( |
|
|
|
call.start_client_batch( |
|
|
|
cygrpc.Operations( |
|
|
|
cygrpc.Operations(( |
|
|
|
(cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS),)), |
|
|
|
cygrpc.operation_receive_initial_metadata(_EMPTY_FLAGS), |
|
|
|
event_handler) |
|
|
|
)), event_handler) |
|
|
|
operations = ( |
|
|
|
operations = ( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_message(serialized_request, _EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_message(serialized_request, |
|
|
|
|
|
|
|
_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_send_close_from_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
call_error = call.start_client_batch( |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
event_handler) |
|
|
|
|
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
drive_call() |
|
|
|
drive_call() |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, |
|
|
|
|
|
|
|
deadline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
|
def __init__(self, channel, managed_call, method, request_serializer, |
|
|
|
self, channel, managed_call, method, request_serializer, |
|
|
|
|
|
|
|
response_deserializer): |
|
|
|
response_deserializer): |
|
|
|
self._channel = channel |
|
|
|
self._channel = channel |
|
|
|
self._managed_call = managed_call |
|
|
|
self._managed_call = managed_call |
|
|
@ -591,8 +597,8 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) |
|
|
|
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
call = self._channel.create_call( |
|
|
|
call = self._channel.create_call(None, 0, completion_queue, |
|
|
|
None, 0, completion_queue, self._method, None, deadline_timespec) |
|
|
|
self._method, None, deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
@ -604,12 +610,12 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
call_error = call.start_client_batch( |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), None) |
|
|
|
cygrpc.Operations(operations), None) |
|
|
|
_check_call_error(call_error, metadata) |
|
|
|
_check_call_error(call_error, metadata) |
|
|
|
_consume_request_iterator( |
|
|
|
_consume_request_iterator(request_iterator, state, call, |
|
|
|
request_iterator, state, call, self._request_serializer) |
|
|
|
self._request_serializer) |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
event = completion_queue.poll() |
|
|
|
event = completion_queue.poll() |
|
|
|
with state.condition: |
|
|
|
with state.condition: |
|
|
@ -619,24 +625,33 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
break |
|
|
|
break |
|
|
|
return state, deadline |
|
|
|
return state, deadline |
|
|
|
|
|
|
|
|
|
|
|
def __call__( |
|
|
|
def __call__(self, |
|
|
|
self, request_iterator, timeout=None, metadata=None, credentials=None): |
|
|
|
request_iterator, |
|
|
|
state, deadline, = self._blocking( |
|
|
|
timeout=None, |
|
|
|
request_iterator, timeout, metadata, credentials) |
|
|
|
metadata=None, |
|
|
|
|
|
|
|
credentials=None): |
|
|
|
|
|
|
|
state, deadline, = self._blocking(request_iterator, timeout, metadata, |
|
|
|
|
|
|
|
credentials) |
|
|
|
return _end_unary_response_blocking(state, False, deadline) |
|
|
|
return _end_unary_response_blocking(state, False, deadline) |
|
|
|
|
|
|
|
|
|
|
|
def with_call( |
|
|
|
def with_call(self, |
|
|
|
self, request_iterator, timeout=None, metadata=None, credentials=None): |
|
|
|
request_iterator, |
|
|
|
state, deadline, = self._blocking( |
|
|
|
timeout=None, |
|
|
|
request_iterator, timeout, metadata, credentials) |
|
|
|
metadata=None, |
|
|
|
|
|
|
|
credentials=None): |
|
|
|
|
|
|
|
state, deadline, = self._blocking(request_iterator, timeout, metadata, |
|
|
|
|
|
|
|
credentials) |
|
|
|
return _end_unary_response_blocking(state, True, deadline) |
|
|
|
return _end_unary_response_blocking(state, True, deadline) |
|
|
|
|
|
|
|
|
|
|
|
def future( |
|
|
|
def future(self, |
|
|
|
self, request_iterator, timeout=None, metadata=None, credentials=None): |
|
|
|
request_iterator, |
|
|
|
|
|
|
|
timeout=None, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
credentials=None): |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) |
|
|
|
state = _RPCState(_STREAM_UNARY_INITIAL_DUE, None, None, None, None) |
|
|
|
call, drive_call = self._managed_call( |
|
|
|
call, drive_call = self._managed_call(None, 0, self._method, None, |
|
|
|
None, 0, self._method, None, deadline_timespec) |
|
|
|
deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
@ -649,23 +664,21 @@ class _StreamUnaryMultiCallable(grpc.StreamUnaryMultiCallable): |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_message(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
call_error = call.start_client_batch( |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
event_handler) |
|
|
|
|
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
drive_call() |
|
|
|
drive_call() |
|
|
|
_consume_request_iterator( |
|
|
|
_consume_request_iterator(request_iterator, state, call, |
|
|
|
request_iterator, state, call, self._request_serializer) |
|
|
|
self._request_serializer) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): |
|
|
|
class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): |
|
|
|
|
|
|
|
|
|
|
|
def __init__( |
|
|
|
def __init__(self, channel, managed_call, method, request_serializer, |
|
|
|
self, channel, managed_call, method, request_serializer, |
|
|
|
|
|
|
|
response_deserializer): |
|
|
|
response_deserializer): |
|
|
|
self._channel = channel |
|
|
|
self._channel = channel |
|
|
|
self._managed_call = managed_call |
|
|
|
self._managed_call = managed_call |
|
|
@ -673,12 +686,15 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): |
|
|
|
self._request_serializer = request_serializer |
|
|
|
self._request_serializer = request_serializer |
|
|
|
self._response_deserializer = response_deserializer |
|
|
|
self._response_deserializer = response_deserializer |
|
|
|
|
|
|
|
|
|
|
|
def __call__( |
|
|
|
def __call__(self, |
|
|
|
self, request_iterator, timeout=None, metadata=None, credentials=None): |
|
|
|
request_iterator, |
|
|
|
|
|
|
|
timeout=None, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
credentials=None): |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
deadline, deadline_timespec = _deadline(timeout) |
|
|
|
state = _RPCState(_STREAM_STREAM_INITIAL_DUE, None, None, None, None) |
|
|
|
state = _RPCState(_STREAM_STREAM_INITIAL_DUE, None, None, None, None) |
|
|
|
call, drive_call = self._managed_call( |
|
|
|
call, drive_call = self._managed_call(None, 0, self._method, None, |
|
|
|
None, 0, self._method, None, deadline_timespec) |
|
|
|
deadline_timespec) |
|
|
|
if credentials is not None: |
|
|
|
if credentials is not None: |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
call.set_credentials(credentials._credentials) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
|
event_handler = _event_handler(state, call, self._response_deserializer) |
|
|
@ -690,16 +706,15 @@ class _StreamStreamMultiCallable(grpc.StreamStreamMultiCallable): |
|
|
|
operations = ( |
|
|
|
operations = ( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
cygrpc.operation_send_initial_metadata( |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
_common.cygrpc_metadata(metadata), _EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS), |
|
|
|
cygrpc.operation_receive_status_on_client(_EMPTY_FLAGS),) |
|
|
|
) |
|
|
|
call_error = call.start_client_batch( |
|
|
|
call_error = call.start_client_batch(cygrpc.Operations(operations), |
|
|
|
cygrpc.Operations(operations), event_handler) |
|
|
|
event_handler) |
|
|
|
|
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
if call_error != cygrpc.CallError.ok: |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
_call_error_set_RPCstate(state, call_error, metadata) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
return _Rendezvous(state, None, None, deadline) |
|
|
|
drive_call() |
|
|
|
drive_call() |
|
|
|
_consume_request_iterator( |
|
|
|
_consume_request_iterator(request_iterator, state, call, |
|
|
|
request_iterator, state, call, self._request_serializer) |
|
|
|
self._request_serializer) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
return _Rendezvous(state, call, self._response_deserializer, deadline) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -713,6 +728,7 @@ class _ChannelCallState(object): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _run_channel_spin_thread(state): |
|
|
|
def _run_channel_spin_thread(state): |
|
|
|
|
|
|
|
|
|
|
|
def channel_spin(): |
|
|
|
def channel_spin(): |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
event = state.completion_queue.poll() |
|
|
|
event = state.completion_queue.poll() |
|
|
@ -736,6 +752,7 @@ def _run_channel_spin_thread(state): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _channel_managed_call_management(state): |
|
|
|
def _channel_managed_call_management(state): |
|
|
|
|
|
|
|
|
|
|
|
def create(parent, flags, method, host, deadline): |
|
|
|
def create(parent, flags, method, host, deadline): |
|
|
|
"""Creates a managed cygrpc.Call and a function to call to drive it. |
|
|
|
"""Creates a managed cygrpc.Call and a function to call to drive it. |
|
|
|
|
|
|
|
|
|
|
@ -754,8 +771,8 @@ def _channel_managed_call_management(state): |
|
|
|
A cygrpc.Call with which to conduct an RPC and a function to call if |
|
|
|
A cygrpc.Call with which to conduct an RPC and a function to call if |
|
|
|
operations are successfully started on the call. |
|
|
|
operations are successfully started on the call. |
|
|
|
""" |
|
|
|
""" |
|
|
|
call = state.channel.create_call( |
|
|
|
call = state.channel.create_call(parent, flags, state.completion_queue, |
|
|
|
parent, flags, state.completion_queue, method, host, deadline) |
|
|
|
method, host, deadline) |
|
|
|
|
|
|
|
|
|
|
|
def drive(): |
|
|
|
def drive(): |
|
|
|
with state.lock: |
|
|
|
with state.lock: |
|
|
@ -766,6 +783,7 @@ def _channel_managed_call_management(state): |
|
|
|
state.managed_calls.add(call) |
|
|
|
state.managed_calls.add(call) |
|
|
|
|
|
|
|
|
|
|
|
return call, drive |
|
|
|
return call, drive |
|
|
|
|
|
|
|
|
|
|
|
return create |
|
|
|
return create |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -810,7 +828,10 @@ def _deliver(state, initial_connectivity, initial_callbacks): |
|
|
|
|
|
|
|
|
|
|
|
def _spawn_delivery(state, callbacks): |
|
|
|
def _spawn_delivery(state, callbacks): |
|
|
|
delivering_thread = threading.Thread( |
|
|
|
delivering_thread = threading.Thread( |
|
|
|
target=_deliver, args=(state, state.connectivity, callbacks,)) |
|
|
|
target=_deliver, args=( |
|
|
|
|
|
|
|
state, |
|
|
|
|
|
|
|
state.connectivity, |
|
|
|
|
|
|
|
callbacks,)) |
|
|
|
delivering_thread.start() |
|
|
|
delivering_thread.start() |
|
|
|
state.delivering = True |
|
|
|
state.delivering = True |
|
|
|
|
|
|
|
|
|
|
@ -823,8 +844,8 @@ def _poll_connectivity(state, channel, initial_try_to_connect): |
|
|
|
state.connectivity = ( |
|
|
|
state.connectivity = ( |
|
|
|
_common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[ |
|
|
|
_common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[ |
|
|
|
connectivity]) |
|
|
|
connectivity]) |
|
|
|
callbacks = tuple( |
|
|
|
callbacks = tuple(callback |
|
|
|
callback for callback, unused_but_known_to_be_none_connectivity |
|
|
|
for callback, unused_but_known_to_be_none_connectivity |
|
|
|
in state.callbacks_and_connectivities) |
|
|
|
in state.callbacks_and_connectivities) |
|
|
|
for callback_and_connectivity in state.callbacks_and_connectivities: |
|
|
|
for callback_and_connectivity in state.callbacks_and_connectivities: |
|
|
|
callback_and_connectivity[1] = state.connectivity |
|
|
|
callback_and_connectivity[1] = state.connectivity |
|
|
@ -832,8 +853,8 @@ def _poll_connectivity(state, channel, initial_try_to_connect): |
|
|
|
_spawn_delivery(state, callbacks) |
|
|
|
_spawn_delivery(state, callbacks) |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
completion_queue = cygrpc.CompletionQueue() |
|
|
|
while True: |
|
|
|
while True: |
|
|
|
channel.watch_connectivity_state( |
|
|
|
channel.watch_connectivity_state(connectivity, |
|
|
|
connectivity, cygrpc.Timespec(time.time() + 0.2), |
|
|
|
cygrpc.Timespec(time.time() + 0.2), |
|
|
|
completion_queue, None) |
|
|
|
completion_queue, None) |
|
|
|
event = completion_queue.poll() |
|
|
|
event = completion_queue.poll() |
|
|
|
with state.lock: |
|
|
|
with state.lock: |
|
|
@ -863,10 +884,13 @@ def _moot(state): |
|
|
|
def _subscribe(state, callback, try_to_connect): |
|
|
|
def _subscribe(state, callback, try_to_connect): |
|
|
|
with state.lock: |
|
|
|
with state.lock: |
|
|
|
if not state.callbacks_and_connectivities and not state.polling: |
|
|
|
if not state.callbacks_and_connectivities and not state.polling: |
|
|
|
|
|
|
|
|
|
|
|
def cancel_all_subscriptions(timeout): |
|
|
|
def cancel_all_subscriptions(timeout): |
|
|
|
_moot(state) |
|
|
|
_moot(state) |
|
|
|
|
|
|
|
|
|
|
|
polling_thread = _common.CleanupThread( |
|
|
|
polling_thread = _common.CleanupThread( |
|
|
|
cancel_all_subscriptions, target=_poll_connectivity, |
|
|
|
cancel_all_subscriptions, |
|
|
|
|
|
|
|
target=_poll_connectivity, |
|
|
|
args=(state, state.channel, bool(try_to_connect))) |
|
|
|
args=(state, state.channel, bool(try_to_connect))) |
|
|
|
polling_thread.start() |
|
|
|
polling_thread.start() |
|
|
|
state.polling = True |
|
|
|
state.polling = True |
|
|
@ -883,8 +907,8 @@ def _subscribe(state, callback, try_to_connect): |
|
|
|
|
|
|
|
|
|
|
|
def _unsubscribe(state, callback): |
|
|
|
def _unsubscribe(state, callback): |
|
|
|
with state.lock: |
|
|
|
with state.lock: |
|
|
|
for index, (subscribed_callback, unused_connectivity) in enumerate( |
|
|
|
for index, (subscribed_callback, unused_connectivity |
|
|
|
state.callbacks_and_connectivities): |
|
|
|
) in enumerate(state.callbacks_and_connectivities): |
|
|
|
if callback == subscribed_callback: |
|
|
|
if callback == subscribed_callback: |
|
|
|
state.callbacks_and_connectivities.pop(index) |
|
|
|
state.callbacks_and_connectivities.pop(index) |
|
|
|
break |
|
|
|
break |
|
|
@ -892,7 +916,8 @@ def _unsubscribe(state, callback): |
|
|
|
|
|
|
|
|
|
|
|
def _options(options): |
|
|
|
def _options(options): |
|
|
|
return list(options) + [ |
|
|
|
return list(options) + [ |
|
|
|
(cygrpc.ChannelArgKey.primary_user_agent_string, _USER_AGENT)] |
|
|
|
(cygrpc.ChannelArgKey.primary_user_agent_string, _USER_AGENT) |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Channel(grpc.Channel): |
|
|
|
class Channel(grpc.Channel): |
|
|
@ -907,8 +932,8 @@ class Channel(grpc.Channel): |
|
|
|
credentials: A cygrpc.ChannelCredentials or None. |
|
|
|
credentials: A cygrpc.ChannelCredentials or None. |
|
|
|
""" |
|
|
|
""" |
|
|
|
self._channel = cygrpc.Channel( |
|
|
|
self._channel = cygrpc.Channel( |
|
|
|
_common.encode(target), _common.channel_args(_options(options)), |
|
|
|
_common.encode(target), |
|
|
|
credentials) |
|
|
|
_common.channel_args(_options(options)), credentials) |
|
|
|
self._call_state = _ChannelCallState(self._channel) |
|
|
|
self._call_state = _ChannelCallState(self._channel) |
|
|
|
self._connectivity_state = _ChannelConnectivityState(self._channel) |
|
|
|
self._connectivity_state = _ChannelConnectivityState(self._channel) |
|
|
|
|
|
|
|
|
|
|
@ -918,28 +943,40 @@ class Channel(grpc.Channel): |
|
|
|
def unsubscribe(self, callback): |
|
|
|
def unsubscribe(self, callback): |
|
|
|
_unsubscribe(self._connectivity_state, callback) |
|
|
|
_unsubscribe(self._connectivity_state, callback) |
|
|
|
|
|
|
|
|
|
|
|
def unary_unary( |
|
|
|
def unary_unary(self, |
|
|
|
self, method, request_serializer=None, response_deserializer=None): |
|
|
|
method, |
|
|
|
|
|
|
|
request_serializer=None, |
|
|
|
|
|
|
|
response_deserializer=None): |
|
|
|
return _UnaryUnaryMultiCallable( |
|
|
|
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) |
|
|
|
_common.encode(method), request_serializer, response_deserializer) |
|
|
|
|
|
|
|
|
|
|
|
def unary_stream( |
|
|
|
def unary_stream(self, |
|
|
|
self, method, request_serializer=None, response_deserializer=None): |
|
|
|
method, |
|
|
|
|
|
|
|
request_serializer=None, |
|
|
|
|
|
|
|
response_deserializer=None): |
|
|
|
return _UnaryStreamMultiCallable( |
|
|
|
return _UnaryStreamMultiCallable( |
|
|
|
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) |
|
|
|
_common.encode(method), request_serializer, response_deserializer) |
|
|
|
|
|
|
|
|
|
|
|
def stream_unary( |
|
|
|
def stream_unary(self, |
|
|
|
self, method, request_serializer=None, response_deserializer=None): |
|
|
|
method, |
|
|
|
|
|
|
|
request_serializer=None, |
|
|
|
|
|
|
|
response_deserializer=None): |
|
|
|
return _StreamUnaryMultiCallable( |
|
|
|
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) |
|
|
|
_common.encode(method), request_serializer, response_deserializer) |
|
|
|
|
|
|
|
|
|
|
|
def stream_stream( |
|
|
|
def stream_stream(self, |
|
|
|
self, method, request_serializer=None, response_deserializer=None): |
|
|
|
method, |
|
|
|
|
|
|
|
request_serializer=None, |
|
|
|
|
|
|
|
response_deserializer=None): |
|
|
|
return _StreamStreamMultiCallable( |
|
|
|
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) |
|
|
|
_common.encode(method), request_serializer, response_deserializer) |
|
|
|
|
|
|
|
|
|
|
|
def __del__(self): |
|
|
|
def __del__(self): |
|
|
|