本文整理汇总了Python中celery.bin.multi.MultiTool.shutdown_nodes方法的典型用法代码示例。如果您正苦于以下问题:Python MultiTool.shutdown_nodes方法的具体用法?Python MultiTool.shutdown_nodes怎么用?Python MultiTool.shutdown_nodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.bin.multi.MultiTool
的用法示例。
在下文中一共展示了MultiTool.shutdown_nodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_MultiTool
# 需要导入模块: from celery.bin.multi import MultiTool [as 别名]
# 或者: from celery.bin.multi.MultiTool import shutdown_nodes [as 别名]
#.........这里部分代码省略.........
def test_help(self):
self.t.help([])
self.assertIn(doc, self.fh.getvalue())
def test_expand(self):
self.t.expand(['foo%n', 'ask', 'klask', 'dask'])
self.assertEqual(
self.fh.getvalue(), 'fooask\nfooklask\nfoodask\n',
)
def test_restart(self):
stop = self.t._stop_nodes = Mock()
self.t.restart(['jerry', 'george'], 'celery worker')
waitexec = self.t.waitexec = Mock()
self.assertTrue(stop.called)
callback = stop.call_args[1]['callback']
self.assertTrue(callback)
waitexec.return_value = 0
callback('jerry', ['arg'], 13)
waitexec.assert_called_with(['arg'])
self.assertIn('OK', self.fh.getvalue())
self.fh.seek(0)
self.fh.truncate()
waitexec.return_value = 1
callback('jerry', ['arg'], 13)
self.assertIn('FAILED', self.fh.getvalue())
def test_stop(self):
self.t.getpids = Mock()
self.t.getpids.return_value = [2, 3, 4]
self.t.shutdown_nodes = Mock()
self.t.stop(['a', 'b', '-INT'], 'celery worker')
self.t.shutdown_nodes.assert_called_with(
[2, 3, 4], sig=signal.SIGINT, retry=None, callback=None,
)
def test_kill(self):
if not hasattr(signal, 'SIGKILL'):
raise SkipTest('SIGKILL not supported by this platform')
self.t.getpids = Mock()
self.t.getpids.return_value = [
('a', None, 10),
('b', None, 11),
('c', None, 12)
]
sig = self.t.signal_node = Mock()
self.t.kill(['a', 'b', 'c'], 'celery worker')
sigs = sig.call_args_list
self.assertEqual(len(sigs), 3)
self.assertEqual(sigs[0][0], ('a', 10, signal.SIGKILL))
self.assertEqual(sigs[1][0], ('b', 11, signal.SIGKILL))
self.assertEqual(sigs[2][0], ('c', 12, signal.SIGKILL))
def prepare_pidfile_for_getpids(self, Pidfile):
class pids(object):
def __init__(self, path):
self.path = path
def read_pid(self):