diff --git a/gnes/service/frontend.py b/gnes/service/frontend.py index 02b5d812..2775a082 100644 --- a/gnes/service/frontend.py +++ b/gnes/service/frontend.py @@ -142,10 +142,18 @@ def StreamCall(self, request_iterator, context): zmq_client.send_message(self.add_envelope(request, zmq_client), self.args.timeout) num_request += 1 - while True: + while num_request > 10: try: # fetch response in real time to reduce network overload - msg = zmq_client.recv_message(10) + timeout = 50 + if self.args.timeout > 0: + timeout = min(0.5 * self.args.timeout, 100) + + # only 1000 pending tasks are approved + if num_request > 1000: + timeout = -1 + + msg = zmq_client.recv_message(timeout) yield self.remove_envelope(msg) num_request -= 1 except TimeoutError: