当前位置: 首页>>代码示例>>Python>>正文


Python service.Service方法代码示例

本文整理汇总了Python中service.Service方法的典型用法代码示例。如果您正苦于以下问题:Python service.Service方法的具体用法?Python service.Service怎么用?Python service.Service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在service的用法示例。


在下文中一共展示了service.Service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def start(service):
    """
    Start a service and wait until it's running.
    """
    ok(service.start(block=TIMEOUT), 'Service failed to start')
    assert_running()
    return service 
开发者ID:torfsen,项目名称:service,代码行数:9,代码来源:test_service.py

示例2: test_start

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_start(self):
        """
        Test ``Service.start``.
        """
        start(WaitingService()) 
开发者ID:torfsen,项目名称:service,代码行数:7,代码来源:test_service.py

示例3: test_start_timeout_ok

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_start_timeout_ok(self):
        """
        Test ``Service.start`` with a timeout.
        """
        ok(WaitingService().start(block=TIMEOUT)) 
开发者ID:torfsen,项目名称:service,代码行数:7,代码来源:test_service.py

示例4: test_start_timeout_fail

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_start_timeout_fail(self):
        """
        Test ``Service.start`` with a timeout and a failing daemon.
        """
        ok(not FailingService().start(block=0.1)) 
开发者ID:torfsen,项目名称:service,代码行数:7,代码来源:test_service.py

示例5: test_stop

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_stop(self):
        """
        Test ``Service.stop``.
        """
        start(WaitingService()).stop()
        time.sleep(DELAY)
        assert_not_running() 
开发者ID:torfsen,项目名称:service,代码行数:9,代码来源:test_service.py

示例6: test_stop_timeout_fail

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_stop_timeout_fail(self):
        """
        Test ``Service.stop`` with a timeout and stuck daemon.
        """
        ok(not start(ForeverService()).stop(block=0.1)) 
开发者ID:torfsen,项目名称:service,代码行数:7,代码来源:test_service.py

示例7: test_kill

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_kill(self):
        """
        Test ``Service.kill``.
        """
        start(ForeverService()).kill()
        time.sleep(DELAY)
        assert_not_running() 
开发者ID:torfsen,项目名称:service,代码行数:9,代码来源:test_service.py

示例8: test_kill_timeout_ok

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_kill_timeout_ok(self):
        """
        Test ``Service.kill`` with a timeout.
        """
        ok(start(ForeverService()).kill(block=TIMEOUT))
        assert_not_running() 
开发者ID:torfsen,项目名称:service,代码行数:8,代码来源:test_service.py

示例9: test_kill_timeout_fail

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_kill_timeout_fail(self):
        """
        Test ``Service.kill`` with too short a timeout.
        """
        os_kill = os.kill

        def kill_mock(pid, sig):
            if sig != signal.SIGKILL:
                return os_kill(pid, sig)

        with mock.patch('os.kill', side_effect=kill_mock):
            ok(not start(ForeverService()).kill(block=0.1)) 
开发者ID:torfsen,项目名称:service,代码行数:14,代码来源:test_service.py

示例10: test_is_running

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def test_is_running(self):
        """
        Test ``Service.is_running``.
        """
        service = WaitingService()
        ok(not service.is_running())
        start(service)
        ok(service.is_running()) 
开发者ID:torfsen,项目名称:service,代码行数:10,代码来源:test_service.py

示例11: run

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def run(self):
        self.createConfig()
        cmd = [ config.Config.CAP.haproxyBin, "-Ds", "-p", self.pidfile, "-f", self.cfgfile ]
        if (os.path.isfile(self.pidfile)):
            os.remove(self.pidfile)
        os.chdir(self.dir)
        log.A.audit(log.A.START, log.A.SERVICE, cmd=" ".join(cmd), serviceid=self.id)
        if self.isClient():
            if (config.Config.CAP.proxycStandalone):
                command = cmd[0]
                if config.Config.CAP.noRun:
                    log.L.warning("Exiting from dispatcher. Run manually:\n%s" % (" ".join(cmd)))
                    atexit.unregister(services.SERVICES.stop)
                    sys.exit()
                else:
                    if not os.path.isfile(config.Config.CAP.haproxyBin):
                        log.L.error("Haproxy binary %s not found. Cannot continue!" % (config.Config.CAP.haproxyBin))
                        sys.exit(1)
                    log.L.warning("Running %s and exiting from dispatcher." % (" ".join(cmd)))
                    os.execv(command, cmd)
        if not os.path.isfile(config.Config.CAP.haproxyBin):
            log.L.error("Haproxy binary %s not found. Cannot continue!" % (config.Config.CAP.haproxyBin))
            sys.exit(1)
        self.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, universal_newlines=True, shell=None)
        self.pid = self.waitForPid()
        log.L.info("Service %s: [pid=%s]" % (self.id, self.pid))
        if self.isClient():
            self.mgmtConnect("127.0.0.1", self.cfg["mgmtport"])
        else:
            self.mgmtConnect("socket", self.mgmtfile)
        super().run() 
开发者ID:LetheanMovement,项目名称:lethean-vpn,代码行数:33,代码来源:service_ha.py

示例12: setUp

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def setUp(self):
        import cxxd_mocks, service
        self.unsupported_request = 0xFF
        self.payload = [0x1, 0x2, 0x3]
        self.service = service.Service(cxxd_mocks.ServicePluginMock()) 
开发者ID:JBakamovic,项目名称:cxxd,代码行数:7,代码来源:test_service.py

示例13: prefetch_models

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def prefetch_models():
    models = ['bist', 'ner', 'intent_extraction']
    for model in models:
        services[model] = Service(model) 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:6,代码来源:serve.py

示例14: get_paragraphs

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def get_paragraphs():
    if not services['machine_comprehension']:
        services['machine_comprehension'] = Service('machine_comprehension')
    return services['machine_comprehension'].get_paragraphs()


# pylint: disable=inconsistent-return-statements 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:9,代码来源:serve.py

示例15: inference

# 需要导入模块: import service [as 别名]
# 或者: from service import Service [as 别名]
def inference(request, body, response):
    """Makes an inference to a certain model"""
    print(body)
    if request.headers.get('CONTENT-TYPE') == 'application/gzip':
        try:
            original_data = gzip.decompress(request.stream.read())
            input_docs = json.loads(str(original_data, 'utf-8'))["docs"]
            model_name = json.loads(str(original_data, 'utf-8'))["model_name"]
        except Exception:
            response.status = hug.HTTP_500
            return {'status': 'unexpected gzip error'}
    elif request.headers.get('CONTENT-TYPE') == 'application/json':
        if isinstance(body, str):
            body = json.loads(body)
        model_name = body.get('model_name')
        input_docs = body.get('docs')
    else:
        response.status = status_codes.HTTP_400
        return {'status': 'Content-Type header must be application/json or application/gzip'}
    if not model_name:
        response.status = status_codes.HTTP_400
        return {'status': 'model_name is required'}
    # If we've already initialized it, no use in reinitializing
    if not services.get(model_name):
        services[model_name] = Service(model_name)
    if not isinstance(input_docs, list):  # check if it's an array instead
        response.status = status_codes.HTTP_400
        return {'status': 'request not in proper format '}
    headers = parse_headers(request.headers)
    parsed_doc = services[model_name].get_service_inference(input_docs, headers)
    resp_format = request.headers["RESPONSE-FORMAT"]
    ret = format_response(resp_format, parsed_doc)
    if request.headers.get('CONTENT-TYPE') == 'application/gzip':
        response.content_type = resp_format
        response.body = ret
        # no return due to the fact that hug seems to assume json type upon return
    else:
        return ret 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:40,代码来源:serve.py


注:本文中的service.Service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。