Пример #1
0
	def is_alive(self, timeout=1):
		try:
			r = _get_current_app(self.config_module).control.ping(destination=[self.hostname], timeout=timeout)
			return self.hostname in flatten_reply(r)
		except IOError:
			# were not up yet...
			return False
Пример #2
0
 def is_alive(self, timeout=1):
     try:
         r = _get_current_app(self.config_module).control.ping(
             destination=[self.hostname], timeout=timeout)
         return self.hostname in flatten_reply(r)
     except IOError:
         # were not up yet...
         return False
Пример #3
0
    def test_flatten_reply(self):
        reply = [
            {'*****@*****.**': {'hello': 10}},
            {'*****@*****.**': {'hello': 20}},
            {'*****@*****.**': {'hello': 30}}
        ]
        with pytest.warns(DuplicateNodenameWarning) as w:
            nodes = control.flatten_reply(reply)

        assert 'Received multiple replies from node name: {0}.'.format(
            next(iter(reply[0]))) in str(w[0].message.args[0])
        assert '*****@*****.**' in nodes
        assert '*****@*****.**' in nodes
Пример #4
0
    def test_flatten_reply(self):
        reply = [
            {'*****@*****.**': {'hello': 10}},
            {'*****@*****.**': {'hello': 20}},
            {'*****@*****.**': {'hello': 30}}
        ]
        with pytest.warns(DuplicateNodenameWarning) as w:
            nodes = control.flatten_reply(reply)

        assert 'Received multiple replies from node name: {}.'.format(
            next(iter(reply[0]))) in str(w[0].message.args[0])
        assert '*****@*****.**' in nodes
        assert '*****@*****.**' in nodes
Пример #5
0
def worker_command(command, destination, **kwargs):
    """
    Synchronous node (celery panel) command.
    """
    kwargs['destination'] = [destination]
    kwargs['reply'] = True

    reply = flatten_reply(cq.control.broadcast(command, **kwargs))

    try:
        return reply[destination]
    except (KeyError, TypeError):
        return None
Пример #6
0
 def test_flatten_reply(self):
     reply = [
         {'*****@*****.**': {'hello': 10}},
         {'*****@*****.**': {'hello': 20}},
         {'*****@*****.**': {'hello': 30}}
     ]
     with warnings.catch_warnings(record=True) as w:
         nodes = control.flatten_reply(reply)
         self.assertIn(
             'multiple replies',
             str(w[-1].message),
         )
         self.assertIn('*****@*****.**', nodes)
         self.assertIn('*****@*****.**', nodes)
Пример #7
0
    def test_flatten_reply(self):
        reply = [
            {"*****@*****.**": {"hello": 10}},
            {"*****@*****.**": {"hello": 20}},
            {"*****@*****.**": {"hello": 30}},
        ]
        with pytest.warns(DuplicateNodenameWarning) as w:
            nodes = control.flatten_reply(reply)

        assert "Received multiple replies from node name: {0}.".format(next(iter(reply[0]))) in str(
            w[0].message.args[0]
        )
        assert "*****@*****.**" in nodes
        assert "*****@*****.**" in nodes
Пример #8
0
    def test_flatten_reply(self):
        reply = [
            {'*****@*****.**': {'hello': 10}},
            {'*****@*****.**': {'hello': 20}},
            {'*****@*****.**': {'hello': 30}}
        ]
        with self.assertWarns(DuplicateNodenameWarning) as w:
            nodes = control.flatten_reply(reply)

        self.assertIn(
            'Received multiple replies from node name: [email protected].',
            str(w.warning)
        )
        self.assertIn('*****@*****.**', nodes)
        self.assertIn('*****@*****.**', nodes)
Пример #9
0
 def is_alive(self, timeout=1):
     r = self.ping(destination=[self.hostname], timeout=timeout)
     return self.hostname in flatten_reply(r)
Пример #10
0
 def my_response(self, response):
     return flatten_reply(response)[self.worker.hostname]
Пример #11
0
 def is_alive(self, timeout=1):
     r = self.ping(destination=[self.hostname], timeout=timeout)
     return self.hostname in flatten_reply(r)
Пример #12
0
 def my_response(self, response):
     return flatten_reply(response)[self.worker.hostname]