How to use the juju.client.watcher function in juju

To help you get started, we’ve selected a few juju examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github juju / juju / acceptancetests / assess_model_change_watcher.py View on Github external
async def listen_to_watcher(event_found, conn, future):
    logging.info("Starting to listen for the watcher.")
    all_watcher = watcher.AllWatcher()
    all_watcher.connect(conn)
    for _ in until_timeout(120):
        logging.info("Listening for events...")
        change = await all_watcher.Next()
        for delta in change.deltas:
            logging.info("Event received: {}".format(str(delta.deltas)))
            if event_found(delta.deltas) is True:
                await all_watcher.Stop()
                await conn.close()
                logging.info("Event found: {}".format(str(delta.deltas)))
                future.set_result(True)
                return

    await all_watcher.Stop()
    await conn.close()
    logging.warning("Event not found.")