Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
feat(stream-call): only 1000 pending tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
felix committed Sep 16, 2019
1 parent b4007ba commit ea89d8c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions gnes/service/frontend.py
Expand Up @@ -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:
Expand Down

0 comments on commit ea89d8c

Please sign in to comment.