當前位置: 首頁>>代碼示例>>Python>>正文


Python PosixReactorBase.__init__方法代碼示例

本文整理匯總了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 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:22,代碼來源:twisted.py

示例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 
開發者ID:omererdem,項目名稱:honeything,代碼行數:21,代碼來源:twisted.py

示例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) 
開發者ID:eliben,項目名稱:code-for-blog,代碼行數:20,代碼來源:qt4reactor.py

示例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 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:9,代碼來源:twisted.py

示例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) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:13,代碼來源:cfreactor.py

示例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) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:6,代碼來源:test_posixbase.py

示例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']) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:28,代碼來源:test_posixbase.py

示例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']) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:28,代碼來源:test_posixbase.py


注:本文中的twisted.internet.posixbase.PosixReactorBase.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。