本文整理匯總了Python中cocaine.services.Service.list方法的典型用法代碼示例。如果您正苦於以下問題:Python Service.list方法的具體用法?Python Service.list怎麽用?Python Service.list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cocaine.services.Service
的用法示例。
在下文中一共展示了Service.list方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import list [as 別名]
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")
示例2: f
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import list [as 別名]
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")
示例3: apps
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import list [as 別名]
def apps(request):
node = Service('node')
list_ = yield node.list()
yield render(request, 'list.html', {
'apps': list_
})
示例4: test_node_service
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import list [as 別名]
def test_node_service():
io = CocaineIO.instance()
node = Service("node", host="localhost", port=10053, loop=io)
channel = node.list().wait(1)
app_list = channel.rx.get().wait(1)
assert isinstance(app_list, list), "invalid app_list type `%s` %s " % (type(app_list), app_list)