本文整理汇总了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)
示例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