本文整理汇总了Python中twisted.internet.interfaces.IReactorTime方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IReactorTime方法的具体用法?Python interfaces.IReactorTime怎么用?Python interfaces.IReactorTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.IReactorTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_timeout_add
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def test_timeout_add(self):
"""
A
L{reactor.callLater<twisted.internet.interfaces.IReactorTime.callLater>}
call scheduled from a C{gobject.timeout_add}
call is run on time.
"""
import gobject
reactor = self.buildReactor()
result = []
def gschedule():
reactor.callLater(0, callback)
return 0
def callback():
result.append(True)
reactor.stop()
reactor.callWhenRunning(gobject.timeout_add, 10, gschedule)
self.runReactor(reactor, 5)
self.assertEqual(result, [True])
示例2: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def __init__(self, clock):
"""
@type clock: L{IReactorTime <interfaces.IReactorTime>} provider
@param clock: A reactor which will be used to learn the current time.
"""
self._clock = clock
示例3: call_later
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def call_later(self, delay, fun, *args, **kwargs):
return IReactorTime(self._get_loop()).callLater(delay, fun, *args, **kwargs)
示例4: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def __init__(self, clock):
# pass clock=reactor unless you're testing
self._clock = IReactorTime(clock)
self._calls = []
self._flush_d = None
self._timer = None
示例5: callLater
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def callLater(self, _seconds, _f, *args, **kw):
"""See twisted.internet.interfaces.IReactorTime.callLater.
"""
assert callable(_f), "%s is not callable" % _f
assert sys.maxint >= _seconds >= 0, \
"%s is not greater than or equal to 0 seconds" % (_seconds,)
tple = DelayedCall(self.seconds() + _seconds, _f, args, kw,
self._cancelCallLater,
self._moveCallLaterSooner,
seconds=self.seconds)
self._newTimedCalls.append(tple)
return tple
示例6: callLater
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def callLater(self, _seconds, _f, *args, **kw):
"""See twisted.internet.interfaces.IReactorTime.callLater.
"""
assert callable(_f), "%s is not callable" % _f
assert sys.maxint >= _seconds >= 0, \
"%s is not greater than or equal to 0 seconds" % (_seconds,)
tple = DelayedCall(seconds() + _seconds, _f, args, kw,
self._cancelCallLater,
self._moveCallLaterSooner)
self._newTimedCalls.append(tple)
return tple
示例7: cancelCallLater
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorTime [as 别名]
def cancelCallLater(self, callID):
"""See twisted.internet.interfaces.IReactorTime.cancelCallLater.
"""
# DO NOT DELETE THIS - this is documented in Python in a Nutshell, so we
# we can't get rid of it for a long time.
warnings.warn("reactor.cancelCallLater(callID) is deprecated - use callID.cancel() instead")
callID.cancel()