本文整理汇总了Python中twisted.internet.posixbase.PosixReactorBase.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python PosixReactorBase.__init__方法的具体用法?Python PosixReactorBase.__init__怎么用?Python PosixReactorBase.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.posixbase.PosixReactorBase
的用法示例。
在下文中一共展示了PosixReactorBase.__init__方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [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: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def __init__(self, io_loop=None):
if not io_loop:
io_loop = tornado.ioloop.IOLoop.instance()
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)
# 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
示例3: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def __init__(self):
self._reads = {}
self._writes = {}
self._timer=QTimer()
self._timer.setSingleShot(True)
if QCoreApplication.startingUp():
self.qApp=QCoreApplication([])
self._ownApp=True
else:
self.qApp = QCoreApplication.instance()
self._ownApp=False
self._blockApp = None
self._readWriteQ=[]
""" some debugging instrumentation """
self._doSomethingCount=0
PosixReactorBase.__init__(self)
示例4: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def __init__(self, reactor, seconds, f, *args, **kw):
self._reactor = reactor
self._func = functools.partial(f, *args, **kw)
self._time = self._reactor.seconds() + seconds
self._timeout = self._reactor._io_loop.add_timeout(self._time,
self._called)
self._active = True
示例5: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def __init__(self, runLoop=None, runner=None):
self._fdmap = {}
self._idmap = {}
if runner is None:
runner = CFRunLoopRun
self._runner = runner
if runLoop is None:
runLoop = CFRunLoopGetMain()
self._cfrunloop = runLoop
PosixReactorBase.__init__(self)
示例6: __init__
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def __init__(self):
self._readers = {}
self._writers = {}
PosixReactorBase.__init__(self)
示例7: test_listenWithIsDeprecated
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def test_listenWithIsDeprecated(self):
"""
L{PosixReactorBase} implements the deprecated L{IReactorArbitrary}, and
L{PosixReactorBase.listenWith} is a part of that interface. To avoid
unnecessary deprecation warnings when importing posixbase, the
L{twisted.internet.interfaces._IReactorArbitrary} alias that doesn't
have the deprecation warning is imported, and instead
L{PosixReactorBase.listenWith} generates its own deprecation warning.
"""
class fakePort:
def __init__(self, *args, **kw):
pass
def startListening(self):
pass
reactor = TrivialReactor()
reactor.listenWith(fakePort)
warnings = self.flushWarnings([self.test_listenWithIsDeprecated])
self.assertEquals(len(warnings), 1)
self.assertEquals(warnings[0]['category'], DeprecationWarning)
self.assertEquals(
"listenWith is deprecated since Twisted 10.1. "
"See IReactorFDSet.",
warnings[0]['message'])
示例8: test_connectWithIsDeprecated
# 需要导入模块: from twisted.internet.posixbase import PosixReactorBase [as 别名]
# 或者: from twisted.internet.posixbase.PosixReactorBase import __init__ [as 别名]
def test_connectWithIsDeprecated(self):
"""
L{PosixReactorBase} implements the deprecated L{IReactorArbitrary}, and
L{PosixReactorBase.connectWith} is a part of that interface. To avoid
unnecessary deprecation warnings when importing posixbase, the
L{twisted.internet.interfaces._IReactorArbitrary} alias that doesn't
have the deprecation warning is imported, and instead
L{PosixReactorBase.connectWith} generates its own deprecation warning.
"""
class fakeConnector:
def __init__(self, *args, **kw):
pass
def connect(self):
pass
reactor = TrivialReactor()
reactor.connectWith(fakeConnector)
warnings = self.flushWarnings([self.test_connectWithIsDeprecated])
self.assertEquals(len(warnings), 1)
self.assertEquals(warnings[0]['category'], DeprecationWarning)
self.assertEquals(
"connectWith is deprecated since Twisted 10.1. "
"See IReactorFDSet.",
warnings[0]['message'])