本文整理匯總了Python中tornado.platform.twisted.TwistedIOLoop方法的典型用法代碼示例。如果您正苦於以下問題:Python twisted.TwistedIOLoop方法的具體用法?Python twisted.TwistedIOLoop怎麽用?Python twisted.TwistedIOLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.platform.twisted
的用法示例。
在下文中一共展示了twisted.TwistedIOLoop方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: save_signal_handlers
# 需要導入模塊: from tornado.platform import twisted [as 別名]
# 或者: from tornado.platform.twisted import TwistedIOLoop [as 別名]
def save_signal_handlers():
saved = {}
for sig in [signal.SIGINT, signal.SIGTERM, signal.SIGCHLD]:
saved[sig] = signal.getsignal(sig)
if "twisted" in repr(saved):
if not issubclass(IOLoop.configured_class(), TwistedIOLoop):
# when the global ioloop is twisted, we expect the signal
# handlers to be installed. Otherwise, it means we're not
# cleaning up after twisted properly.
raise Exception("twisted signal handlers already installed")
return saved
示例2: stop
# 需要導入模塊: from tornado.platform import twisted [as 別名]
# 或者: from tornado.platform.twisted import TwistedIOLoop [as 別名]
def stop(self):
# One of twisted's tests fails if I don't delay crash()
# until the reactor has started, but if I move this to
# TwistedIOLoop then the tests fail when I'm *not* running
# tornado-on-twisted-on-tornado. I'm clearly missing something
# about the startup/crash semantics, but since stop and crash
# are really only used in tests it doesn't really matter.
def f():
self.reactor.crash()
# Become current again on restart. This is needed to
# override real_io_loop's claim to being the current loop.
self.add_callback(self.make_current)
self.reactor.callWhenRunning(f)
示例3: stop
# 需要導入模塊: from tornado.platform import twisted [as 別名]
# 或者: from tornado.platform.twisted import TwistedIOLoop [as 別名]
def stop(self):
# One of twisted's tests fails if I don't delay crash()
# until the reactor has started, but if I move this to
# TwistedIOLoop then the tests fail when I'm *not* running
# tornado-on-twisted-on-tornado. I'm clearly missing something
# about the startup/crash semantics, but since stop and crash
# are really only used in tests it doesn't really matter.
self.reactor.callWhenRunning(self.reactor.crash)