当前位置: 首页>>代码示例>>Python>>正文


Python reactor.fireSystemEvent函数代码示例

本文整理汇总了Python中twisted.internet.reactor.fireSystemEvent函数的典型用法代码示例。如果您正苦于以下问题:Python fireSystemEvent函数的具体用法?Python fireSystemEvent怎么用?Python fireSystemEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fireSystemEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_subsequentBeforeTriggerFiresPriorBeforeDeferred

 def test_subsequentBeforeTriggerFiresPriorBeforeDeferred(self):
     """
     If a trigger added to the C{'before'} phase of an event calls back a
     L{Deferred} returned by an earlier trigger in the C{'before'} phase of
     the same event, the remaining C{'before'} triggers for that event
     should be run and any further L{Deferred}s waited on before proceeding
     to the C{'during'} events.
     """
     eventType = 'test'
     events = []
     firstDeferred = Deferred()
     secondDeferred = Deferred()
     def firstBeforeTrigger():
         return firstDeferred
     def secondBeforeTrigger():
         firstDeferred.callback(None)
     def thirdBeforeTrigger():
         events.append('before')
         return secondDeferred
     def duringTrigger():
         events.append('during')
     self.addTrigger('before', eventType, firstBeforeTrigger)
     self.addTrigger('before', eventType, secondBeforeTrigger)
     self.addTrigger('before', eventType, thirdBeforeTrigger)
     self.addTrigger('during', eventType, duringTrigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, ['before'])
     secondDeferred.callback(None)
     self.assertEqual(events, ['before', 'during'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:30,代码来源:test_internet.py

示例2: test_multipleBeforeReturnDeferred

 def test_multipleBeforeReturnDeferred(self):
     """
     If more than one trigger added to the C{'before'} phase of an event
     return L{Deferred}s, the C{'during'} phase should be delayed until they
     are all called back.
     """
     firstDeferred = Deferred()
     secondDeferred = Deferred()
     eventType = 'test'
     events = []
     def firstBeforeTrigger():
         return firstDeferred
     def secondBeforeTrigger():
         return secondDeferred
     def duringTrigger():
         events.append('during')
     self.addTrigger('before', eventType, firstBeforeTrigger)
     self.addTrigger('before', eventType, secondBeforeTrigger)
     self.addTrigger('during', eventType, duringTrigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, [])
     firstDeferred.callback(None)
     self.assertEqual(events, [])
     secondDeferred.callback(None)
     self.assertEqual(events, ['during'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:26,代码来源:test_internet.py

示例3: signal_handler

def signal_handler(signal, frame):
        print 'You pressed Ctrl+C'
        # As per here:
        # http://www.tornadoweb.org/documentation/twisted.html
        reactor.fireSystemEvent('shutdown')
        reactor.disconnectAll()
        sys.exit(0)
开发者ID:brianmcdonnell,项目名称:pycon_ie_2012,代码行数:7,代码来源:server-06a-tx-db-translate.py

示例4: exit_reactor

def exit_reactor(res):
    if reactor.running:
        #Manually firing shutdown triggers
        logging.info('Shutting down twisted reactor')
        reactor.fireSystemEvent('shutdown')
        reactor.stop()
    sys.exit(res)
开发者ID:subodhtirkey,项目名称:FiSH,代码行数:7,代码来源:app.py

示例5: start

 def start():
     try:
         OscInterface("Test", 8000)
     except:
         import traceback
         traceback.print_exc()
         print >> sys.stderr, "Caught exception during startup."
         reactor.fireSystemEvent('shutdown')
开发者ID:yangfuyuan,项目名称:andosc_teleop,代码行数:8,代码来源:andosc_teleop.py

示例6: start

 def start():
     print "roam_node2 starting..."
     try:
         RoamNode()
     except:
         import traceback
         traceback.print_exc()
         print >> sys.stderr, "\nCaught exception during startup. Shutting down."
         reactor.fireSystemEvent('shutdown')
开发者ID:PR2,项目名称:linux_networking,代码行数:9,代码来源:roam_node2.py

示例7: _addSystemEventTriggerTest

 def _addSystemEventTriggerTest(self, phase):
     eventType = 'test'
     events = []
     def trigger():
         events.append(None)
     self.addTrigger(phase, eventType, trigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, [None])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_internet.py

示例8: _bail

 def _bail(self):
     from twisted.internet import reactor
     d = defer.Deferred()
     reactor.addSystemEventTrigger('after', 'shutdown',
                                   lambda: d.callback(None))
     reactor.fireSystemEvent('shutdown') # radix's suggestion
     # As long as TestCase does crap stuff with the reactor we need to
     # manually shutdown the reactor here, and that requires util.wait
     # :(
     # so that the shutdown event completes
     unittest.TestCase('mktemp')._wait(d)
开发者ID:shelmesky,项目名称:twisted,代码行数:11,代码来源:runner.py

示例9: _bail

    def _bail(self):
        from twisted.internet import reactor
        d = defer.Deferred()
        reactor.addSystemEventTrigger('after', 'shutdown', lambda: d.callback(None))
        reactor.fireSystemEvent('shutdown') # radix's suggestion

        treactor = interfaces.IReactorThreads(reactor, None)
        if treactor is not None:
            treactor.suggestThreadPoolSize(0)

        util.wait(d) # so that the shutdown event completes
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:11,代码来源:runner.py

示例10: test_interactionBetweenDifferentEvents

    def test_interactionBetweenDifferentEvents(self):
        """
        L{IReactorCore.fireSystemEvent} should behave the same way for a
        particular system event regardless of whether Deferreds are being
        waited on for a different system event.
        """
        events = []

        firstEvent = "first-event"
        firstDeferred = Deferred()

        def beforeFirstEvent():
            events.append(("before", "first"))
            return firstDeferred

        def afterFirstEvent():
            events.append(("after", "first"))

        secondEvent = "second-event"
        secondDeferred = Deferred()

        def beforeSecondEvent():
            events.append(("before", "second"))
            return secondDeferred

        def afterSecondEvent():
            events.append(("after", "second"))

        self.addTrigger("before", firstEvent, beforeFirstEvent)
        self.addTrigger("after", firstEvent, afterFirstEvent)
        self.addTrigger("before", secondEvent, beforeSecondEvent)
        self.addTrigger("after", secondEvent, afterSecondEvent)

        self.assertEqual(events, [])

        # After this, firstEvent should be stuck before 'during' waiting for
        # firstDeferred.
        reactor.fireSystemEvent(firstEvent)
        self.assertEqual(events, [("before", "first")])

        # After this, secondEvent should be stuck before 'during' waiting for
        # secondDeferred.
        reactor.fireSystemEvent(secondEvent)
        self.assertEqual(events, [("before", "first"), ("before", "second")])

        # After this, firstEvent should have finished completely, but
        # secondEvent should be at the same place.
        firstDeferred.callback(None)
        self.assertEqual(events, [("before", "first"), ("before", "second"), ("after", "first")])

        # After this, secondEvent should have finished completely.
        secondDeferred.callback(None)
        self.assertEqual(events, [("before", "first"), ("before", "second"), ("after", "first"), ("after", "second")])
开发者ID:yucheng1992,项目名称:Heuristic-problem-solving,代码行数:53,代码来源:test_internet.py

示例11: test_beforePreceedsDuring

 def test_beforePreceedsDuring(self):
     """
     L{IReactorCore.addSystemEventTrigger} should call triggers added to the
     C{'before'} phase before it calls triggers added to the C{'during'}
     phase.
     """
     eventType = 'test'
     events = []
     def beforeTrigger():
         events.append('before')
     def duringTrigger():
         events.append('during')
     self.addTrigger('before', eventType, beforeTrigger)
     self.addTrigger('during', eventType, duringTrigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, ['before', 'during'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:17,代码来源:test_internet.py

示例12: test_duringPreceedsAfter

 def test_duringPreceedsAfter(self):
     """
     L{IReactorCore.addSystemEventTrigger} should call triggers added to the
     C{'during'} phase before it calls triggers added to the C{'after'}
     phase.
     """
     eventType = 'test'
     events = []
     def duringTrigger():
         events.append('during')
     def afterTrigger():
         events.append('after')
     self.addTrigger('during', eventType, duringTrigger)
     self.addTrigger('after', eventType, afterTrigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, ['during', 'after'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:17,代码来源:test_internet.py

示例13: test_removeSystemEventTrigger

 def test_removeSystemEventTrigger(self):
     """
     A trigger removed with L{IReactorCore.removeSystemEventTrigger} should
     not be called when the event fires.
     """
     eventType = 'test'
     events = []
     def firstBeforeTrigger():
         events.append('first')
     def secondBeforeTrigger():
         events.append('second')
     self.addTrigger('before', eventType, firstBeforeTrigger)
     self.removeTrigger(
         self.addTrigger('before', eventType, secondBeforeTrigger))
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, ['first'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:17,代码来源:test_internet.py

示例14: test_removeSystemEventTrigger

    def test_removeSystemEventTrigger(self):
        """
        A trigger removed with L{IReactorCore.removeSystemEventTrigger} should
        not be called when the event fires.
        """
        eventType = "test"
        events = []

        def firstBeforeTrigger():
            events.append("first")

        def secondBeforeTrigger():
            events.append("second")

        self.addTrigger("before", eventType, firstBeforeTrigger)
        self.removeTrigger(self.addTrigger("before", eventType, secondBeforeTrigger))
        self.assertEqual(events, [])
        reactor.fireSystemEvent(eventType)
        self.assertEqual(events, ["first"])
开发者ID:yucheng1992,项目名称:Heuristic-problem-solving,代码行数:19,代码来源:test_internet.py

示例15: test_beforeReturnsDeferred

 def test_beforeReturnsDeferred(self):
     """
     If a trigger added to the C{'before'} phase of an event returns a
     L{Deferred}, the C{'during'} phase should be delayed until it is called
     back.
     """
     triggerDeferred = Deferred()
     eventType = 'test'
     events = []
     def beforeTrigger():
         return triggerDeferred
     def duringTrigger():
         events.append('during')
     self.addTrigger('before', eventType, beforeTrigger)
     self.addTrigger('during', eventType, duringTrigger)
     self.assertEqual(events, [])
     reactor.fireSystemEvent(eventType)
     self.assertEqual(events, [])
     triggerDeferred.callback(None)
     self.assertEqual(events, ['during'])
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:20,代码来源:test_internet.py


注:本文中的twisted.internet.reactor.fireSystemEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。