Skip to content
Permalink
Browse files

fix(grpc): add max_message_size to the argparser

  • Loading branch information...
hanxiao committed Aug 9, 2019
1 parent 68d2568 commit e516646f09db17069ed96d591f3bbcc4243e47f4
Showing with 11 additions and 11 deletions.
  1. +2 −1 README.md
  2. +2 −4 gnes/cli/parser.py
  3. +2 −2 gnes/client/cli.py
  4. +2 −2 gnes/client/http.py
  5. +1 −0 gnes/service/base.py
  6. +2 −2 gnes/service/grpc.py
@@ -36,7 +36,8 @@
<a href="#documentation">Documentation</a> •
<a href="#tutorial">Tutorial</a> •
<a href="#contributing">Contributing</a> •
<a href="./CHANGELOG.md">Release Notes</a>
<a href="./CHANGELOG.md">Release Notes</a>
<a href="https://hanxiao.github.io/2019/07/29/Generic-Neural-Elastic-Search-From-bert-as-service-and-Go-Way-Beyond/">Blog</a>
</p>

<h2 align="center">What is it</h2>
@@ -217,6 +217,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)')
return parser


@@ -231,10 +233,6 @@ def set_grpc_frontend_parser(parser=None):
read_only=True)
parser.add_argument('--max_concurrency', type=int, default=10,
help='maximum concurrent client allowed')
parser.add_argument('--max_send_size', type=int, default=100,
help='maximum send size for grpc server in (MB)')
parser.add_argument('--max_receive_size', type=int, default=100,
help='maximum receive size for grpc server in (MB)')
return parser


@@ -37,8 +37,8 @@ def __init__(self, args):

with grpc.insecure_channel(
'%s:%s' % (args.grpc_host, args.grpc_port),
options=[('grpc.max_send_message_length', 70 * 1024 * 1024),
('grpc.max_receive_message_length', 70 * 1024 * 1024)]) as channel:
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:
stub = gnes_pb2_grpc.GnesRPCStub(channel)

if args.mode == 'train':
@@ -94,8 +94,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', 100 * 1024 * 1024),
('grpc.max_receive_message_length', 100 * 1024 * 1024),
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),
('grpc.keepalive_timeout_ms', 100 * 1000)]) as channel:
stub = gnes_pb2_grpc.GnesRPCStub(channel)
loop.run_until_complete(init(loop))
@@ -114,6 +114,7 @@ def build_socket(ctx: 'zmq.Context', host: str, port: int, socket_type: 'SocketT
}[socket_type]()

if socket_type.is_bind:
host = BaseService.default_host
if port is None:
sock.bind_to_random_port('tcp://%s' % host)
else:
@@ -146,8 +146,8 @@ def __init__(self, args):
self.logger = set_logger(self.__class__.__name__, args.verbose)
self.server = grpc.server(
futures.ThreadPoolExecutor(max_workers=args.max_concurrency),
options=[('grpc.max_send_message_length', args.max_send_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_receive_size * 1024 * 1024)])
options=[('grpc.max_send_message_length', args.max_message_size * 1024 * 1024),
('grpc.max_receive_message_length', args.max_message_size * 1024 * 1024)])
self.logger.info('start a grpc server with %d workers' % args.max_concurrency)
gnes_pb2_grpc.add_GnesRPCServicer_to_server(GNESServicer(args), self.server)

0 comments on commit e516646

Please sign in to comment.
You can’t perform that action at this time.