Allow "None" as response message with none-OK status

pull/22665/head
Lidi Zheng 5 years ago
parent 17d75dde69
commit 51e38fa508
  1. 12
      src/python/grpcio/grpc/_cython/_cygrpc/aio/server.pyx.pxi
  2. 5
      src/python/grpcio/grpc/_cython/_cygrpc/operation.pyx.pxi

@ -264,14 +264,10 @@ async def _finish_handler_with_unary_response(RPCState rpc_state,
rpc_state.raise_for_termination() rpc_state.raise_for_termination()
# Serializes the response message # Serializes the response message
cdef bytes response_raw cdef bytes response_raw = serialize(
if rpc_state.status_code == StatusCode.ok: response_serializer,
response_raw = serialize( response_message,
response_serializer, )
response_message,
)
else:
response_raw = b''
# Assembles the batch operations # Assembles the batch operations
cdef tuple finish_ops cdef tuple finish_ops

@ -49,7 +49,10 @@ cdef class SendInitialMetadataOperation(Operation):
cdef class SendMessageOperation(Operation): cdef class SendMessageOperation(Operation):
def __cinit__(self, bytes message, int flags): def __cinit__(self, bytes message, int flags):
self._message = message if message is None:
self._message = b''
else:
self._message = message
self._flags = flags self._flags = flags
def type(self): def type(self):

Loading…
Cancel
Save