X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=examples%2Fallwatcher.py;h=c215d20cb33ef66ac21e8ec63bf577428930c0ae;hb=ed0017cc2049050002f23d1b9e1ef95ff8448e5c;hp=ecd6e82cd730bfde280f4991e651cccbe68f8edb;hpb=660a58aa232d250480dce53b64880482837d3160;p=osm%2FN2VC.git diff --git a/examples/allwatcher.py b/examples/allwatcher.py index ecd6e82..c215d20 100644 --- a/examples/allwatcher.py +++ b/examples/allwatcher.py @@ -12,10 +12,12 @@ import logging from juju.client.connection import Connection from juju.client import watcher +from juju import loop async def watch(): allwatcher = watcher.AllWatcher() + conn = await Connection.connect_current() allwatcher.connect(conn) while True: change = await allwatcher.Next() @@ -23,7 +25,8 @@ async def watch(): print(delta.deltas) -logging.basicConfig(level=logging.DEBUG) -loop = asyncio.get_event_loop() -conn = loop.run_until_complete(Connection.connect_current()) -loop.run_until_complete(watch()) +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + # Run loop until the process is manually stopped (watch will loop + # forever). + loop.run(watch())