aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Nathaniel Manista <nathaniel@google.com>2017-01-20 21:05:47 +0000
committerGravatar Nathaniel Manista <nathaniel@google.com>2017-01-20 23:14:46 +0000
commit7d561a6328caedaf7404af8d9015e465d3630810 (patch)
tree56da49e0bef8f78ba7b8c2c4c863aac187b36e22 /src
parent00ac6288fd5be1100310fcead8f46d199da4c823 (diff)
Fix grpc._server._Context.time_remaining
A weak test is included; proper test coverage will come later.
Diffstat (limited to 'src')
-rw-r--r--src/python/grpcio/grpc/_server.py5
-rw-r--r--src/python/grpcio_tests/tests/unit/_rpc_test.py5
2 files changed, 8 insertions, 2 deletions
diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py
index 158cdf8b0e..cbbe2dcbf5 100644
--- a/src/python/grpcio/grpc/_server.py
+++ b/src/python/grpcio/grpc/_server.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()
diff --git a/src/python/grpcio_tests/tests/unit/_rpc_test.py b/src/python/grpcio_tests/tests/unit/_rpc_test.py
index 2cf6dfea62..2b1c85a82d 100644
--- a/src/python/grpcio_tests/tests/unit/_rpc_test.py
+++ b/src/python/grpcio_tests/tests/unit/_rpc_test.py
@@ -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):