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


Python KQueueMonitor.shutdown_event方法代码示例

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


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

示例1: test_start

# 需要导入模块: from celery.worker.autoreload import KQueueMonitor [as 别名]
# 或者: from celery.worker.autoreload.KQueueMonitor import shutdown_event [as 别名]
    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,代码行数:34,代码来源:test_autoreload.py

示例2: test_start

# 需要导入模块: from celery.worker.autoreload import KQueueMonitor [as 别名]
# 或者: from celery.worker.autoreload.KQueueMonitor import shutdown_event [as 别名]
    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,代码行数:39,代码来源:test_autoreload.py


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