• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reactor.fireSystemEvent函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_wsgi

    def test_wsgi(self):
        """
        The I{--wsgi} option takes the fully-qualifed Python name of a WSGI
        application object and creates a L{WSGIResource} at the root which
        serves that application.
        """
        options = Options()
        options.parseOptions(['--wsgi', __name__ + '.application'])
        root = options['root']
        self.assertTrue(root, WSGIResource)
        self.assertIdentical(root._reactor, reactor)
        self.assertTrue(isinstance(root._threadpool, ThreadPool))
        self.assertIdentical(root._application, application)

        # The threadpool should start and stop with the reactor.
        self.assertFalse(root._threadpool.started)
        reactor.fireSystemEvent('startup')
        self.assertTrue(root._threadpool.started)
        self.assertFalse(root._threadpool.joined)
        reactor.fireSystemEvent('shutdown')
        self.assertTrue(root._threadpool.joined)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:21,代码来源:test_tap.py


示例17: test_system_events_triggered

    def test_system_events_triggered(self):
        batons = list()
        stub_pipeline_provider = StubPipelineProvider(batons.append)
        self.runtime_environment.resource_manager.register('pipeline.test_pipeline', stub_pipeline_provider)
        
        provider = system_events_provider.SystemEventsProvider()

        configuration_manager = self.runtime_environment.configuration_manager

        for event_type in 'startup', 'shutdown':
            configuration_manager.set('system-events.%s.name' % event_type, 'test_pipeline')

        provider.configure(self.runtime_environment)

        self.runtime_environment.dependency_manager.resolve_initial_states()

        # wait a reactor iteration so the startup event is triggered
        yield util.wait(0)
        self.assertEquals(batons, [dict(event_type='startup')])
        batons[:] = list()

        # trigger the shutdown event, which should give our pipeline a baton
        reactor.fireSystemEvent('shutdown')
        self.assertEquals(batons, [dict(event_type='shutdown')])
开发者ID:alexbrasetvik,项目名称:Piped,代码行数:24,代码来源:test_system_events_provider.py


示例18: stop

 def stop(self):
     if reactor.running:
         log.info("Stopping the reactor")
         reactor.fireSystemEvent("shutdown")
开发者ID:zhilinwww,项目名称:lbry,代码行数:4,代码来源:DaemonServer.py


示例19: exit_callback

 def exit_callback():
     log.msg("Exiting due to timeout (--exit-timeout/-t)")
     reactor.fireSystemEvent('shutdown')
     #reactor.stop()
     sys.exit(12)
开发者ID:0dayZh,项目名称:SocketRocket,代码行数:5,代码来源:runner.py


示例20: iterate

      client.keys.from_network(msg)


  def iterate(self, step=0):
    self.reactor.iterate(step)

  def broadcast(self, msg):
    for address in list(self.active):
      client = self.active[address]
      client.time_to_live -= 1

      if client.time_to_live == 0:
        self.removed_monkeys.append(client.monkey)
        del self.active[address]
        continue

      client_id = client.monkey.player_id
      client_tag = str(client_id)+','
      self.transport.write(client_tag + msg, address)

  def shutdown(self):
    self.reactor.fireSystemEvent('shutdown')

# Singleton
Server = Server(reactor)
reactor.listenUDP(8007, Server)
reactor.fireSystemEvent('startup')


开发者ID:0xfaded,项目名称:JungleSwanging,代码行数:27,代码来源:server.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python reactor.getDelayedCalls函数代码示例发布时间:2022-05-27
下一篇:
Python reactor.crash函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap