本文整理汇总了Python中twisted.internet.posixbase.PosixReactorBase.crash方法的典型用法代码示例。如果您正苦于以下问题:Python PosixReactorBase.crash方法的具体用法?Python PosixReactorBase.crash怎么用?Python PosixReactorBase.crash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.posixbase.PosixReactorBase
的用法示例。
在下文中一共展示了PosixReactorBase.crash方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def __init__(self, io_loop=None):
if not io_loop:
io_loop = tornado.ioloop.IOLoop.current()
self._io_loop = io_loop
self._readers = {} # map of reader objects to fd
self._writers = {} # map of writer objects to fd
self._fds = {} # a map of fd to a (reader, writer) tuple
self._delayedCalls = {}
PosixReactorBase.__init__(self)
self.addSystemEventTrigger('during', 'shutdown', self.crash)
# IOLoop.start() bypasses some of the reactor initialization.
# Fire off the necessary events if they weren't already triggered
# by reactor.run().
def start_if_necessary():
if not self._started:
self.fireSystemEvent('startup')
self._io_loop.add_callback(start_if_necessary)
# IReactorTime
示例2: crash
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def crash(self):
PosixReactorBase.crash(self)
self._io_loop.stop()
示例3: stop
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def stop(self):
self.reactor.crash()
示例4: mainLoop
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def mainLoop(self):
"""
Run the runner (C{CFRunLoopRun} or something that calls it), which runs
the run loop until C{crash()} is called.
"""
self._inCFLoop = True
try:
self._runner()
finally:
self._inCFLoop = False
示例5: _scheduleSimulate
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def _scheduleSimulate(self, force=False):
"""
Schedule a call to C{self.runUntilCurrent}. This will cancel the
currently scheduled call if it is already scheduled.
@param force: Even if there are no timed calls, make sure that
C{runUntilCurrent} runs immediately (in a 0-seconds-from-now
C{CFRunLoopTimer}). This is necessary for calls which need to
trigger behavior of C{runUntilCurrent} other than running timed
calls, such as draining the thread call queue or calling C{crash()}
when the appropriate flags are set.
@type force: C{bool}
"""
if self._currentSimulator is not None:
CFRunLoopTimerInvalidate(self._currentSimulator)
self._currentSimulator = None
timeout = self.timeout()
if force:
timeout = 0.0
if timeout is not None:
fireDate = (CFAbsoluteTimeGetCurrent() + timeout)
def simulate(cftimer, extra):
self._currentSimulator = None
self.runUntilCurrent()
self._scheduleSimulate()
c = self._currentSimulator = CFRunLoopTimerCreate(
kCFAllocatorDefault, fireDate,
0, 0, 0, simulate, None
)
CFRunLoopAddTimer(self._cfrunloop, c, kCFRunLoopCommonModes)
示例6: crash
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def crash(self):
"""
Implement L{IReactorCore.crash}
"""
wasStarted = self._started
PosixReactorBase.crash(self)
if self._inCFLoop:
self._stopNow()
else:
if wasStarted:
self.callLater(0, self._stopNow)
示例7: mainLoop
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def mainLoop(self):
"""
Run the runner (L{CFRunLoopRun} or something that calls it), which runs
the run loop until C{crash()} is called.
"""
self._inCFLoop = True
try:
self._runner()
finally:
self._inCFLoop = False
示例8: _scheduleSimulate
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import crash [as 别名]
def _scheduleSimulate(self, force=False):
"""
Schedule a call to C{self.runUntilCurrent}. This will cancel the
currently scheduled call if it is already scheduled.
@param force: Even if there are no timed calls, make sure that
C{runUntilCurrent} runs immediately (in a 0-seconds-from-now
{CFRunLoopTimer}). This is necessary for calls which need to
trigger behavior of C{runUntilCurrent} other than running timed
calls, such as draining the thread call queue or calling C{crash()}
when the appropriate flags are set.
@type force: C{bool}
"""
if self._currentSimulator is not None:
CFRunLoopTimerInvalidate(self._currentSimulator)
self._currentSimulator = None
timeout = self.timeout()
if force:
timeout = 0.0
if timeout is not None:
fireDate = (CFAbsoluteTimeGetCurrent() + timeout)
def simulate(cftimer, extra):
self._currentSimulator = None
self.runUntilCurrent()
self._scheduleSimulate()
c = self._currentSimulator = CFRunLoopTimerCreate(
kCFAllocatorDefault, fireDate,
0, 0, 0, simulate, None
)
CFRunLoopAddTimer(self._cfrunloop, c, kCFRunLoopCommonModes)