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


Python autoreload.KQueueMonitor类代码示例

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


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

示例1: test_start

    def test_start(self, osopen, kevent, kqueue):
        prev = {}
        flags = ["KQ_FILTER_VNODE", "KQ_EV_ADD", "KQ_EV_ENABLE",
                 "KQ_EV_CLEAR", "KQ_NOTE_WRITE", "KQ_NOTE_EXTEND"]
        for i, flag in enumerate(flags):
            prev[flag] = getattr(select, flag, None)
            if not prev[flag]:
                setattr(select, flag, i)
        try:
            kq = kqueue.return_value = Mock()

            class ev(object):
                ident = 10
            kq.control.return_value = [ev()]
            x = KQueueMonitor(["a"])
            osopen.return_value = 10
            calls = [0]

            def on_is_set():
                calls[0] += 1
                if calls[0] > 2:
                    return True
                return False
            x.shutdown_event = Mock()
            x.shutdown_event.is_set.side_effect = on_is_set
            x.start()
        finally:
            for flag in flags:
                if prev[flag]:
                    setattr(select, flag, prev[flag])
                else:
                    delattr(select, flag)
开发者ID:ahalife,项目名称:celery,代码行数:32,代码来源:test_autoreload.py

示例2: test_register_with_event_loop_no_kqueue

 def test_register_with_event_loop_no_kqueue(self):
     from kombu.utils import eventio
     prev, eventio.kqueue = eventio.kqueue, None
     try:
         x = KQueueMonitor(['a'])
         x.register_with_event_loop(Mock())
     finally:
         eventio.kqueue = prev
开发者ID:JohnSpeno,项目名称:celery,代码行数:8,代码来源:test_autoreload.py

示例3: test_handle_event

 def test_handle_event(self):
     x = KQueueMonitor(['a', 'b'])
     x.on_change = Mock()
     eA = Mock()
     eA.ident = 'a'
     eB = Mock()
     eB.ident = 'b'
     x.fdmap = {'a': 'A', 'b': 'B'}
     x.handle_event([eA, eB])
     x.on_change.assert_called_with(['A', 'B'])
开发者ID:1995rishi,项目名称:flaskmap,代码行数:10,代码来源:test_autoreload.py

示例4: test_register_with_event_loop

 def test_register_with_event_loop(self, kqueue):
     x = KQueueMonitor(['a', 'b'])
     hub = Mock(name='hub')
     x.add_events = Mock(name='add_events()')
     x.register_with_event_loop(hub)
     x.add_events.assert_called_with(x._kq)
     self.assertEqual(
         x._kq.on_file_change,
         x.handle_event,
     )
开发者ID:JohnSpeno,项目名称:celery,代码行数:10,代码来源:test_autoreload.py

示例5: test_on_poll_init

 def test_on_poll_init(self):
     x = KQueueMonitor(['a', 'b'])
     hub = Mock()
     x.add_events = Mock()
     x.on_poll_init(hub)
     x.add_events.assert_called_with(hub.poller)
     self.assertEqual(
         hub.poller.on_file_change,
         x.handle_event,
     )
开发者ID:charettes,项目名称:celery,代码行数:10,代码来源:test_autoreload.py

示例6: test_register_with_event_loop

 def test_register_with_event_loop(self):
     x = KQueueMonitor(['a', 'b'])
     hub = Mock()
     x.add_events = Mock()
     x.register_with_event_loop(hub)
     x.add_events.assert_called_with(hub.poller)
     self.assertEqual(
         hub.poller.on_file_change,
         x.handle_event,
     )
开发者ID:AnSavvides,项目名称:celery,代码行数:10,代码来源:test_autoreload.py

示例7: test_register_with_event_loop

 def test_register_with_event_loop(self):
     from kombu.utils import eventio
     if eventio.kqueue is None:
         raise SkipTest('version of kombu does not work with pypy')
     x = KQueueMonitor(['a', 'b'])
     hub = Mock(name='hub')
     x.add_events = Mock(name='add_events()')
     x.register_with_event_loop(hub)
     x.add_events.assert_called_with(x._kq)
     self.assertEqual(
         x._kq.on_file_change,
         x.handle_event,
     )
开发者ID:1995rishi,项目名称:flaskmap,代码行数:13,代码来源:test_autoreload.py

示例8: test_stop

    def test_stop(self, close, kqueue):
        x = KQueueMonitor(['a', 'b'])
        x.poller = Mock()
        x.filemap['a'] = 10
        x.stop()
        x.poller.close.assert_called_with()
        close.assert_called_with(10)

        close.side_effect = OSError()
        close.side_effect.errno = errno.EBADF
        x.stop()
开发者ID:1995rishi,项目名称:flaskmap,代码行数:11,代码来源:test_autoreload.py

示例9: test_stop

    def test_stop(self, close, kqueue):
        x = KQueueMonitor(["a", "b"])
        x._kq = Mock()
        x.filemap["a"] = 10
        x.stop()
        x._kq.close.assert_called_with()
        close.assert_called_with(10)

        close.side_effect = OSError()
        close.side_effect.errno = errno.EBADF
        x.stop()
开发者ID:ahalife,项目名称:celery,代码行数:11,代码来源:test_autoreload.py

示例10: test_start

    def test_start(self, _kq, osopen, kevent, kqueue):
        from kombu.utils import eventio
        prev_poll, eventio.poll = eventio.poll, kqueue
        prev = {}
        flags = ['KQ_FILTER_VNODE', 'KQ_EV_ADD', 'KQ_EV_ENABLE',
                 'KQ_EV_CLEAR', 'KQ_NOTE_WRITE', 'KQ_NOTE_EXTEND']
        for i, flag in enumerate(flags):
            prev[flag] = getattr(eventio, flag, None)
            if not prev[flag]:
                setattr(eventio, flag, i)
        try:
            kq = kqueue.return_value = Mock()

            class ev(object):
                ident = 10
                filter = eventio.KQ_FILTER_VNODE
                fflags = eventio.KQ_NOTE_WRITE
            kq.control.return_value = [ev()]
            x = KQueueMonitor(['a'])
            osopen.return_value = 10
            calls = [0]

            def on_is_set():
                calls[0] += 1
                if calls[0] > 2:
                    return True
                return False
            x.shutdown_event = Mock()
            x.shutdown_event.is_set.side_effect = on_is_set
            x.start()
        finally:
            for flag in flags:
                if prev[flag]:
                    setattr(eventio, flag, prev[flag])
                else:
                    delattr(eventio, flag)
            eventio.poll = prev_poll
开发者ID:1995rishi,项目名称:flaskmap,代码行数:37,代码来源:test_autoreload.py

示例11: test_on_event_loop_close

 def test_on_event_loop_close(self):
     x = KQueueMonitor(['a', 'b'])
     x.close = Mock()
     x._kq = Mock(name='_kq')
     x.on_event_loop_close(Mock(name='hub'))
     x.close.assert_called_with(x._kq)
开发者ID:1995rishi,项目名称:flaskmap,代码行数:6,代码来源:test_autoreload.py

示例12: test_on_poll_close

 def test_on_poll_close(self):
     x = KQueueMonitor(['a', 'b'])
     x.close = Mock()
     hub = Mock()
     x.on_poll_close(hub)
     x.close.assert_called_with(hub.poller)
开发者ID:charettes,项目名称:celery,代码行数:6,代码来源:test_autoreload.py


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