本文整理匯總了Python中cocaine.services.Service.perform_sync方法的典型用法代碼示例。如果您正苦於以下問題:Python Service.perform_sync方法的具體用法?Python Service.perform_sync怎麽用?Python Service.perform_sync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cocaine.services.Service
的用法示例。
在下文中一共展示了Service.perform_sync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __new__
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import perform_sync [as 別名]
def __new__(cls):
if not hasattr(cls, "_instanse"):
instanse = object.__new__(cls)
try:
_logger = Service("logging")
for verbosity in _logger.perform_sync("verbosity"): #only one chunk and read choke also.
pass
setattr(instanse, "_logger", _logger)
try:
setattr(instanse, "target", "app/%s" % sys.argv[sys.argv.index("--app") + 1])
except ValueError:
setattr(instanse, "target", "app/%s" % "standalone" )
_construct_logger_methods(instanse, verbosity)
except Exception as err:
instanse = _STDERR_Logger()
instanse.warn("Logger init error: %s. Use stderr logger" % err)
cls._instanse = instanse
return cls._instanse
示例2: on
# 需要導入模塊: from cocaine.services import Service [as 別名]
# 或者: from cocaine.services.Service import perform_sync [as 別名]
# coding=utf-8
from tornado.ioloop import IOLoop
from cocaine.services import Service
__author__ = 'EvgenySafronov <[email protected]>'
if __name__ == '__main__2':
def on(chunk):
print('Response received - {0}'.format(chunk))
loop.stop()
def error(exception):
print('Error received - {0}'.format(exception))
loop.stop()
service = Service('Echo')
future = service.invoke('doIt', 'SomeMessage')
future.bind(on, error)
loop = IOLoop.instance()
loop.start()
if __name__ == '__main__':
service = Service('Echo')
for chunk in service.perform_sync('invoke', 'doIt', 'SomeMessage'):
print('Response received - {0}'.format(chunk))