本文整理匯總了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)