From 63f9173f3ecbd6d2e4836fa7b1d01736f854c002 Mon Sep 17 00:00:00 2001 From: hanhxiao Date: Wed, 7 Aug 2019 18:47:01 +0800 Subject: [PATCH] feat(service): enabling the choose of thread or process as the backend --- gnes/cli/api.py | 32 ++++++++++++++++---------------- gnes/service/base.py | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gnes/cli/api.py b/gnes/cli/api.py index 804adbe5..fac05079 100644 --- a/gnes/cli/api.py +++ b/gnes/cli/api.py @@ -16,6 +16,12 @@ # pylint: disable=low-comment-ratio +def preprocess(args): + from ..service.preprocessor import PreprocessorService + with PreprocessorService(args) as es: + es.join() + + def encode(args): from ..service.encoder import EncoderService with EncoderService(args) as es: @@ -34,16 +40,6 @@ def route(args): es.join() -def compose(args): - from ..composer.base import YamlComposer - from ..composer.flask import YamlComposerFlask - - if args.flask: - YamlComposerFlask(args).run() - else: - YamlComposer(args).build_all() - - def frontend(args): from ..service.grpc import GRPCFrontend import threading @@ -52,12 +48,6 @@ def frontend(args): forever.wait() -def preprocess(args): - from ..service.preprocessor import PreprocessorService - with PreprocessorService(args) as es: - es.join() - - def client_http(args): from ..client.http import HttpClient HttpClient(args).start() @@ -66,3 +56,13 @@ def client_http(args): def client_cli(args): from ..client.cli import CLIClient CLIClient(args) + + +def compose(args): + from ..composer.base import YamlComposer + from ..composer.flask import YamlComposerFlask + + if args.flask: + YamlComposerFlask(args).run() + else: + YamlComposer(args).build_all() diff --git a/gnes/service/base.py b/gnes/service/base.py index e30d319d..b47925a6 100644 --- a/gnes/service/base.py +++ b/gnes/service/base.py @@ -170,7 +170,7 @@ def __call__(cls, *args, **kwargs): }[args[0].concurrency_backend] # rebuild the class according to mro - for c in cls.mro()[::-1][1:]: + for c in cls.mro()[-2::-1]: arg_cls = ConcurrentService._dct[c.__name__]['cls'] arg_name = ConcurrentService._dct[c.__name__]['name'] arg_dct = ConcurrentService._dct[c.__name__]['dct']