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

Commit

Permalink
fix(parser): remove limite on message size
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Sep 12, 2019
1 parent cc72cf2 commit 00c25f3
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions gnes/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ def _set_grpc_parser(parser=None):
type=int,
default=8800,
help='host port of the grpc service')
parser.add_argument('--max_message_size', type=int, default=100,
help='maximum send and receive size for grpc server in (MB)')
parser.add_argument('--max_message_size', type=int, default=-1,
help='maximum send and receive size for grpc server in bytes, -1 means unlimited')
return parser


Expand Down
4 changes: 2 additions & 2 deletions gnes/client/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, args):

with grpc.insecure_channel(
'%s:%d' % (args.grpc_host, args.grpc_port),
options=[('grpc.max_send_message_length', args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_message_size * 1024 * 1024)]) as channel:
options=[('grpc.max_send_message_length', args.max_message_size),
('grpc.max_receive_message_length', args.max_message_size)]) as channel:
stub = gnes_pb2_grpc.GnesRPCStub(channel)

id = 0
Expand Down
11 changes: 8 additions & 3 deletions gnes/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def __init__(self, args=None):
self.logger = set_logger(self.__class__.__name__, self.args.verbose)

def start(self):
from aiohttp import web
try:
from aiohttp import web
except ImportError:
self.logger.error('can not import aiohttp, it is not installed correctly. please do '
'"pip install gnes[aiohttp]"')
return
loop = asyncio.get_event_loop()
executor = ThreadPoolExecutor(max_workers=self.args.max_workers)

Expand Down Expand Up @@ -94,8 +99,8 @@ def stub_call(req):

with grpc.insecure_channel(
'%s:%s' % (self.args.grpc_host, self.args.grpc_port),
options=[('grpc.max_send_message_length', self.args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', self.args.max_message_size * 1024 * 1024),
options=[('grpc.max_send_message_length', self.args.max_message_size),
('grpc.max_receive_message_length', self.args.max_message_size),
('grpc.keepalive_timeout_ms', 100 * 1000)]) as channel:
stub = gnes_pb2_grpc.GnesRPCStub(channel)
loop.run_until_complete(init(loop))
Expand Down
4 changes: 2 additions & 2 deletions gnes/service/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def __init__(self, args):
self.logger = set_logger(self.__class__.__name__, args.verbose)
self.server = grpc.server(
ThreadPoolExecutor(max_workers=args.max_concurrency),
options=[('grpc.max_send_message_length', args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_message_size * 1024 * 1024)])
options=[('grpc.max_send_message_length', args.max_message_size),
('grpc.max_receive_message_length', args.max_message_size)])
self.logger.info('start a frontend with %d workers' % args.max_concurrency)
gnes_pb2_grpc.add_GnesRPCServicer_to_server(self._Servicer(args), self.server)

Expand Down
4 changes: 2 additions & 2 deletions gnes/service/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class GRPCService(BS):
def post_init(self):
self.channel = grpc.insecure_channel(
'%s:%s' % (self.args.grpc_host, self.args.grpc_port),
options=[('grpc.max_send_message_length', self.args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', self.args.max_message_size * 1024 * 1024)])
options=[('grpc.max_send_message_length', self.args.max_message_size),
('grpc.max_receive_message_length', self.args.max_message_size)])

m = PathImporter.add_modules(self.args.pb2_path, self.args.pb2_grpc_path)

Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
'protobuf',
'grpcio',
'ruamel.yaml>=0.15.89',
'pyzmq>=17.1.0',
'aiohttp']
'pyzmq>=17.1.0']

# using pip install gnes[xx] is depreciated
# extras_dep is kept for legacy issue, will be removed soon
Expand All @@ -73,7 +72,9 @@
'onnx': ['onnxruntime'],
'audio': ['librosa>=0.7.0'],
'scipy': ['scipy', 'sklearn'],
'flask': ['flask']
'flask': ['flask'],
'aiohttp': ['aiohttp'],
'http': ['flask', 'aiohttp']
}


Expand Down

0 comments on commit 00c25f3

Please sign in to comment.