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
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
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
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
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
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)
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
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)
def is_alive(self, timeout=1): r = self.ping(destination=[self.hostname], timeout=timeout) return self.hostname in flatten_reply(r)
def my_response(self, response): return flatten_reply(response)[self.worker.hostname]