本文整理汇总了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
示例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
示例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()
#.........这里部分代码省略.........