當前位置: 首頁>>代碼示例>>Python>>正文


Python Service.perform_sync方法代碼示例

本文整理匯總了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
開發者ID:mou,項目名稱:cocaine-framework-python,代碼行數:20,代碼來源:logger.py

示例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))
開發者ID:m0sth8,項目名稱:cocaine-framework-python,代碼行數:28,代碼來源:check.py


注:本文中的cocaine.services.Service.perform_sync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。