As the answer in the question: how-do-i-handle-streaming-messages-with-python-grpc, @Nathaniel provides a solution to handle request and response.
But when I want to statistics the process time of every response, it just doesn't look right. For example, I sleep 200ms in my stream_iter
, but the tr
even less than 200. My code:
t0 = time.time()
for rsp in stub.Process(stream_iter()):
tr = (time.time() - t0) * 1000
print(tr)
t0 = time.time()
...
So I want to know how to timing?