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


Python services.Service类代码示例

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


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

示例1: test_node_service_bad_on_read

def test_node_service_bad_on_read():
    io = IOLoop.current()
    node = Service("node", endpoints=[["localhost", 10053]], io_loop=io)
    malformed_message = msgpack.packb([-999, 0])
    node.on_read(malformed_message)
    message = msgpack.packb([-999, 0, []])
    node.on_read(message)
开发者ID:Alukardd,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_main.py

示例2: f

 def f():
     io = IOLoop.current()
     node = Service("node", endpoints=[["localhost", 10053]], io_loop=io)
     channel = yield node.list()
     app_list = yield channel.rx.get()
     assert isinstance(app_list, list)
     raise gen.Return("OK")
开发者ID:gabrielferreira,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_main.py

示例3: stop_app

 def stop_app(self, appname):
     succeed = list()
     failed = list()
     hosts_count = len(self.hosts)
     for i, host in enumerate(self.hosts):
         log.info("Stop %s at host %d/%d %s" % (appname, i, hosts_count, host))
         nodeinstance = None
         try:
             nodeinstance = Service("node", blockingConnect=False)
             yield nodeinstance.connect(host=host)
             res = yield app.Stop(nodeinstance, appname).execute()
             self.logcallback(str(res) + "\n")
         except Exception as e:
             item = "Unable to connect to node at host %s %s\n" % (host, e)
             log.error(item)
             self.logcallback(item)
             failed.append(host)
         else:
             item = "App %s has been stoped successfully\n" % appname
             log.info(item)
             self.logcallback(item)
             succeed.append(host)
         finally:
             if nodeinstance is not None:
                 nodeinstance.disconnect()
     yield (succeed, failed)
开发者ID:noxiouz,项目名称:infinite-flow,代码行数:26,代码来源:nodecluster.py

示例4: test_node_service_bad_on_read

def test_node_service_bad_on_read():
    io = CocaineIO.instance()
    node = Service("node", host="localhost", port=10053, loop=io)
    malformed_message = msgpack.packb([-999, 0])
    node.on_read(malformed_message)
    message = msgpack.packb([-999, 0, []])
    node.on_read(message)
开发者ID:mwf,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_main.py

示例5: main

def main():
    warning = "1; app status broken: "
    error = "2; depth is full: "
    node = Service("node")
    try:
        chan = yield node.list()
    except:
        print "1; error while connect to service node"
        exit(0)
    app_list = yield chan.rx.get()
    for name in app_list:
        app = Service(name)
        try:
            chan = yield app.info()
            info = yield chan.rx.get()
            if info["queue"]["depth"] == info["queue"]["capacity"]:
                if name != "v012-karma":
                    error = error + name + ","
        except:
            warning = warning + name + ","
    if error != "2; depth is full: ":
        print (error)
    elif warning != "1; app status broken: ":
        print (warning)
    else:
        print ("0;Ok")
开发者ID:borislitv,项目名称:cocaine-script,代码行数:26,代码来源:cocaine-check-depth.py

示例6: f

 def f():
     io = IOLoop.current()
     storage = Service("storage", endpoints=[["localhost", 10053]], io_loop=io)
     channel = yield storage.find('app', ['apps'])
     app_list = yield channel.rx.get()
     assert isinstance(app_list, list)
     raise gen.Return("OK")
开发者ID:Alukardd,项目名称:cocaine-framework-python,代码行数:7,代码来源:test_main.py

示例7: get_service

    def get_service(self, name, request):
        # cache isn't full for the current application
        if len(self.cache[name]) < self.spoolSize:
            logger = request.logger
            try:
                app = Service(name, locator=self.locator, timeout=RESOLVE_TIMEOUT)
                logger.info("%s: creating an instance of %s", app.id, name)
                self.cache[name].append(app)
                yield app.connect(request.traceid)
                logger.info("%s: connect to an app %s endpoint %s ",
                            app.id, app.name, "{0}:{1}".format(*app.address))

                timeout = (1 + random.random()) * self.refreshPeriod
                self.io_loop.call_later(timeout, self.move_to_inactive(app, name))
            except Exception as err:
                logger.error("%s: unable to connect to `%s`: %s", app.id, name, err)
                if app in self.cache[name]:
                    self.cache[name].remove(app)
                raise gen.Return()
            else:
                raise gen.Return(app)

        # get an instance from cache
        chosen = random.choice(self.cache[name])
        raise gen.Return(chosen)
开发者ID:werehuman,项目名称:cocaine-tools,代码行数:25,代码来源:proxy.py

示例8: func3

def func3(args):
    print "Start"
    s = Service("storage")
    try:
        k = yield s.write("A", "A", "KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK", [])
    except Exception as err:
        print err
    print "END"
开发者ID:ijon,项目名称:cocaine-framework-python,代码行数:8,代码来源:chaining.py

示例9: main

def main():
    locator = Service("locator")
    try:
        yield locator.connect()
    except:
        print "2; error while connect to locator"
        exit(1)
    print "0;Ok"
开发者ID:borislitv,项目名称:cocaine-script,代码行数:8,代码来源:cocaine-check-locator.py

示例10: process_synchronous

    def process_synchronous(self, cocaine_service_name, cocaine_method, data):
        """Synchronous Cocaine worker handling."""
        self.log("In process_synchronous()")
        service = Service(cocaine_service_name)
        response = service.enqueue(cocaine_method, msgpack.dumps(data)).get()

        service.disconnect()
        self.log("process_synchronous() finished")
        return response
开发者ID:mwf,项目名称:tornado_cocaine_test,代码行数:9,代码来源:handlers.py

示例11: process_asynchronous

    def process_asynchronous(self, cocaine_service_name, cocaine_method, data):
        """Run selected service and get all chunks as generator."""
        self.log("In process_asynchronous()")
        service = Service(cocaine_service_name)

        chunks_g = service.enqueue(cocaine_method, msgpack.dumps(data))

        yield chunks_g
        service.disconnect()
        self.log("process_asynchronous() finished")
开发者ID:mwf,项目名称:tornado_cocaine_test,代码行数:10,代码来源:handlers.py

示例12: get_service_with_seed

    def get_service_with_seed(self, name, seed, request):
        logger = request.logger
        app = Service(name, seed=seed, locator=self.locator)
        try:
            logger.info("%s: creating an instance of %s, seed %s", app.id, name, seed)
            yield app.connect(logger.traceid)
        except Exception as err:
            logger.error("%s: unable to connect to `%s`: %s", app.id, name, err)
            raise gen.Return()

        raise gen.Return(app)
开发者ID:werehuman,项目名称:cocaine-tools,代码行数:11,代码来源:proxy.py

示例13: raw

def raw(request, response):
    inc  = yield request.read()
    goapp = Service("gococaine")
    storage = Service("storage")
    # Send data to the  go application
    response.write("Send data to the go application")
    key = yield goapp.enqueue("process", str(inc))
    response.write("Data was processed and saved to the storage, key: %s" % key)
    # Read data from storage
    res = yield storage.read("namespace", key)
    response.write(res)
    response.close()
开发者ID:elmato,项目名称:flask-cocaine-pycon,代码行数:12,代码来源:main.py

示例14: main

def main():
    locator = Service("locator")
    try:
        yield locator.connect()
    except:
        print "1; error while connect to locator"
        exit(1)
    try:
        chan = yield locator.resolve("graphite")
        result = yield chan.rx.get()
    except:
        print "2; error while resolv service graphite"
        exit(1)
    print "0;Ok"
开发者ID:borislitv,项目名称:cocaine-script,代码行数:14,代码来源:cocaine-check-graphite.py

示例15: execute

 def execute(self):
     appNames = yield self.node.list()
     appInfoList = {}
     for appName in appNames:
         info = ''
         try:
             app = Service(appName, blockingConnect=False)
             yield app.connectThroughLocator(self.locator)
             info = yield app.info()
         except Exception as err:
             info = str(err)
         finally:
             appInfoList[appName] = info
     result = {
         'apps': appInfoList
     }
     yield result
开发者ID:ApelSYN,项目名称:cocaine-tools,代码行数:17,代码来源:common.py


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