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


Python LoopingCall.a方法代码示例

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


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

示例1: make_lc

# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import a [as 别名]
def make_lc(self, reactor, func):

    if DEBUG:
        self.stdout_length = 0
        self.stderr_length = 0

    def _(lc, reactor):
        if DEBUG:
            stdout = self.stdout.getvalue()
            stderr = self.stderr.getvalue()

            if self.stdout.getvalue()[self.stdout_length:]:
                print(self.stdout.getvalue()[self.stdout_length:],
                      file=sys.__stdout__)
            if self.stderr.getvalue()[self.stderr_length:]:
                print(self.stderr.getvalue()[self.stderr_length:],
                      file=sys.__stderr__)

            self.stdout_length = len(stdout)
            self.stderr_length = len(stderr)

        return func(lc, reactor)

    lc = LoopingCall(_)
    lc.a = (lc, reactor)
    lc.clock = reactor
    lc.start(0.1)
    return lc
开发者ID:snowattitudes,项目名称:crossbar,代码行数:30,代码来源:test_run.py

示例2: create

# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import a [as 别名]
	def create(self):
		if self._connected is not None:
			return self._connected

		MODULE.info('Starting new module process: %s' % (self.module,))
		self.socket = self.get_socket_path()

		args = [
			MODULE_COMMAND, '-l', self.module_locale,
			'-d', str(self.module_debug_level), self.socket, self.module
		]

		MODULE.info('Module process: %s' % (' '.join(args)))
		self.process = Popen(args, executable=MODULE_COMMAND, shell=False)  # TODO: stdout, stderr

		connect = LoopingCall(self.connect)
		connect.a = (connect,)  # twisteds arguments
		self._connected = connect.start(0.05)
		return self._connected
开发者ID:spaceone,项目名称:univention-management-console,代码行数:21,代码来源:process.py

示例3: _test_start_run

# 需要导入模块: from twisted.internet.task import LoopingCall [as 别名]
# 或者: from twisted.internet.task.LoopingCall import a [as 别名]
    def _test_start_run(self):
        """
        A basic start, that enters the reactor.
        """
        code_location = os.path.abspath(self.mktemp())
        os.mkdir(code_location)

        with open(self.config, "w") as f:
            f.write("""{
   "controller": {
   },
   "workers": [
      {
         "type": "router",
         "options": {
            "pythonpath": ["."]
         },
         "realms": [
            {
               "name": "realm1",
               "roles": [
                  {
                     "name": "anonymous",
                     "permissions": [
                        {
                           "uri": "*",
                           "publish": true,
                           "subscribe": true,
                           "call": true,
                           "register": true
                        }
                     ]
                  }
               ]
            }
         ],
         "transports": [
            {
               "type": "web",
               "endpoint": {
                  "type": "tcp",
                  "port": 8080
               },
               "paths": {
            "/": {
              "directory": ".",
              "type": "static"
            },
                  "ws": {
                     "type": "websocket"
                  }
               }
            }
         ]
      },
      {
         "type": "container",
         "options": {
            "pythonpath": ["%s"]
         },
         "components": [
            {
               "type": "class",
               "classname": "test.AppSession",
               "realm": "realm1",
               "transport": {
                  "type": "websocket",
                  "endpoint": {
                     "type": "tcp",
                     "host": "127.0.0.1",
                     "port": 8080
                  },
                  "url": "ws://127.0.0.1:8080/ws"
               }
            }
         ]
      }
   ]
}
            """ % ("/".join(code_location.split(os.sep),)))

        with open(code_location + "/test.py", "w") as f:
            f.write("""#!/usr/bin/env python
from twisted.internet.defer import inlineCallbacks
from twisted.logger import Logger
from autobahn.twisted.wamp import ApplicationSession
from autobahn.wamp.exception import ApplicationError

class AppSession(ApplicationSession):

    log = Logger()

    @inlineCallbacks
    def onJoin(self, details):
        self.log.info("Loaded the component!")
        yield self.publish("com.bar", "test")
""")

        reactor = SelectReactor()

#.........这里部分代码省略.........
开发者ID:joebos,项目名称:crossbar,代码行数:103,代码来源:test_cli.py


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