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