Skip to content
Permalink
Browse files

feat(grpc): add proxy argument to cli

  • Loading branch information...
hanxiao committed Oct 12, 2019
1 parent e64bc7a commit 7265f76c084b0f599b5522be9e9da6684fe3c03a
Showing with 12 additions and 3 deletions.
  1. +4 −0 gnes/cli/parser.py
  2. +4 −0 gnes/client/base.py
  3. +0 −3 gnes/flow/__init__.py
  4. +4 −0 gnes/service/frontend.py
@@ -308,6 +308,10 @@ def _set_grpc_parser(parser=None):
help='host port of the grpc service')
parser.add_argument('--max_message_size', type=int, default=-1,
help='maximum send and receive size for grpc server in bytes, -1 means unlimited')
parser.add_argument('--proxy', action=ActionNoYes, default=False,
help='respect the http_proxy and https_proxy environment variables. '
'otherwise, it will unset these proxy variables before start. '
'gRPC seems perfer --no_proxy')
return parser


@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from typing import Tuple, List, Union

import grpc
@@ -120,6 +121,9 @@ class GrpcClient:

def __init__(self, args):
self.args = args
if not args.proxy:
os.unsetenv('http_proxy')
os.unsetenv('https_proxy')
self.logger = set_logger(self.__class__.__name__, self.args.verbose)
self.logger.info('setting up grpc insecure channel...')
# A gRPC channel provides a connection to a remote gRPC server.
@@ -1,5 +1,4 @@
import copy
import os
from collections import OrderedDict, defaultdict
from contextlib import ExitStack
from functools import wraps
@@ -226,8 +225,6 @@ def query(self, bytes_gen: Iterator[bytes] = None, **kwargs):

@_build_level(BuildLevel.RUNTIME)
def _call_client(self, bytes_gen: Iterator[bytes] = None, **kwargs):
os.unsetenv('http_proxy')
os.unsetenv('https_proxy')
args, p_args = self._get_parsed_args(self, set_client_cli_parser, kwargs)
p_args.grpc_port = self._service_nodes[self._frontend]['parsed_args'].grpc_port
p_args.grpc_host = self._service_nodes[self._frontend]['parsed_args'].grpc_host
@@ -14,6 +14,7 @@
# limitations under the License.


import os
import threading
from concurrent.futures import ThreadPoolExecutor

@@ -28,6 +29,9 @@
class FrontendService:

def __init__(self, args):
if not args.proxy:
os.unsetenv('http_proxy')
os.unsetenv('https_proxy')
self.logger = set_logger(self.__class__.__name__, args.verbose)
self.server = grpc.server(
ThreadPoolExecutor(max_workers=args.max_concurrency),

0 comments on commit 7265f76

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