本文整理汇总了Python中twisted.internet.error.ReactorAlreadyInstalledError方法的典型用法代码示例。如果您正苦于以下问题:Python error.ReactorAlreadyInstalledError方法的具体用法?Python error.ReactorAlreadyInstalledError怎么用?Python error.ReactorAlreadyInstalledError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.error
的用法示例。
在下文中一共展示了error.ReactorAlreadyInstalledError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: installReactor
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def installReactor(reactor):
"""
Install reactor C{reactor}.
@param reactor: An object that provides one or more IReactor* interfaces.
"""
# this stuff should be common to all reactors.
import twisted.internet
import sys
if 'twisted.internet.reactor' in sys.modules:
raise error.ReactorAlreadyInstalledError("reactor already installed")
twisted.internet.reactor = reactor
sys.modules['twisted.internet.reactor'] = reactor
示例2: test_alreadyInstalled
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def test_alreadyInstalled(self):
"""
If a reactor is already installed, L{installReactor} raises
L{ReactorAlreadyInstalledError}.
"""
with NoReactor():
installReactor(object())
self.assertRaises(ReactorAlreadyInstalledError, installReactor,
object())
示例3: test_errorIsAnAssertionError
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def test_errorIsAnAssertionError(self):
"""
For backwards compatibility, L{ReactorAlreadyInstalledError} is an
L{AssertionError}.
"""
self.assertTrue(issubclass(ReactorAlreadyInstalledError,
AssertionError))
示例4: install_reactor
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def install_reactor():
from twisted.internet import gtk3reactor
from twisted.internet.error import ReactorAlreadyInstalledError
try:
# needed for GLib.idle_add, and signals
gtk3reactor.install()
except ReactorAlreadyInstalledError:
pass
示例5: test_alreadyInstalled
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def test_alreadyInstalled(self):
"""
If a reactor is already installed, L{installReactor} raises
L{ReactorAlreadyInstalledError}.
"""
# Because this test runs in trial, assume a reactor is already
# installed.
self.assertRaises(ReactorAlreadyInstalledError, installReactor,
object())
示例6: init_asyncio_reactor
# 需要导入模块: from twisted.internet import error [as 别名]
# 或者: from twisted.internet.error import ReactorAlreadyInstalledError [as 别名]
def init_asyncio_reactor():
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
try:
asyncioreactor.install()
except error.ReactorAlreadyInstalledError:
pass