def ps(self, **kwargs): from mcloud.remote import Client client = Client(host=self.host, settings=self.settings) try: yield client.connect() tasks = yield client.task_list() print tasks except ConnectionRefusedError: print 'Can\'t connect to mcloud server' yield client.shutdown() yield sleep(0.01)