Fix grpc._server._Context.time_remaining

A weak test is included; proper test coverage will come later.
pull/9420/head
Nathaniel Manista 8 years ago
parent 00ac6288fd
commit 7d561a6328
  1. 5
      src/python/grpcio/grpc/_server.py
  2. 5
      src/python/grpcio_tests/tests/unit/_rpc_test.py

@ -233,8 +233,9 @@ class _Context(grpc.ServicerContext):
return self._state.client is not _CANCELLED and not self._state.statused
def time_remaining(self):
return max(self._rpc_event.request_call_details.deadline - time.time(),
0)
return max(
float(self._rpc_event.request_call_details.deadline) - time.time(),
0)
def cancel(self):
self._rpc_event.operation_call.cancel()

@ -81,6 +81,11 @@ class _Handler(object):
servicer_context.set_trailing_metadata(((
'testkey',
'testvalue',),))
# TODO(https://github.com/grpc/grpc/issues/8483): test the values
# returned by these methods rather than only "smoke" testing that
# the return after having been called.
servicer_context.is_active()
servicer_context.time_remaining()
return request
def handle_unary_stream(self, request, servicer_context):

Loading…
Cancel
Save