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

Commit

Permalink
Merge pull request #313 from gnes-ai/fix_client_
Browse files Browse the repository at this point in the history
fix(client): fix bugs for client
  • Loading branch information
mergify[bot] authored Oct 10, 2019
2 parents 3aab341 + 6f40190 commit 17f9287
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions gnes/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def get_default_fn(r_type):
fn = self.routes.get(resp_type)
else:
fn = get_default_fn(type(resp))

self.logger.info('handling response with %s' % fn.__name__)
return fn(self._context, resp)
self.logger.info('handling response with %s' % fn.__name__)
return fn(self._context, resp)
else:
self.logger.warning('the received message is not response')
return None


class ZmqClient:
Expand Down
8 changes: 4 additions & 4 deletions gnes/client/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class StreamingClient(GrpcClient):
def __init__(self, args):
super().__init__(args)

self._request_queue = queue.Queue(maxsize=1000)
self._request_queue = queue.Queue(maxsize=10)
self._is_streaming = threading.Event()

self._dispatch_thread = threading.Thread(target=self._start)
Expand All @@ -63,16 +63,16 @@ def _start(self):
self._is_streaming.clear()

def _request_generator(self):
while self._is_streaming.is_set():
while True:
try:
request = self._request_queue.get(block=True, timeout=5.0)
if request is None:
break
yield request
except queue.Empty:
continue
break
except Exception as e:
print('exception: %s' % str(e))
self.logger.error('exception: %s' % str(e))
break

@handler.register(NotImplementedError)
Expand Down
1 change: 1 addition & 0 deletions gnes/preprocessor/video/frame_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
else:
idx = np.sort(np.random.choice(len(images), self.sframes, replace=False))
chunk.blob.CopyFrom(array2blob(images[idx]))
del images
else:
self.logger.error(
'bad document: "doc.chunks" is empty!')
3 changes: 3 additions & 0 deletions gnes/service/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ def get_response(num_recv, blocked=False):
with self.zmq_context as zmq_client:

for request in request_iterator:
num_recv = max(self.pending_request - self.args.max_pending_request, 0)
yield from get_response(num_recv, num_recv > 0)

zmq_client.send_message(self.add_envelope(request, zmq_client), **self.send_recv_kwargs)
self.pending_request += 1

Expand Down

0 comments on commit 17f9287

Please sign in to comment.