X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=docs%2Freadme.rst;h=ecfbc5a4b90600949baf988ac55e1da585a7265d;hb=eac6d53d640fec2d1adab425c0ce891136b5784b;hp=efb8495dc3b076bd557828ddeb44f7291b21aba5;hpb=5ad9b9d20df199802417d1a5480942afeccbf119;p=osm%2FN2VC.git diff --git a/docs/readme.rst b/docs/readme.rst index efb8495..ecfbc5a 100644 --- a/docs/readme.rst +++ b/docs/readme.rst @@ -5,7 +5,7 @@ Source code: https://github.com/juju/python-libjuju Bug reports: https://github.com/juju/python-libjuju/issues -Documentation: https://pythonhosted.org/juju/ +Documentation: https://pythonlibjuju.readthedocs.io/en/latest/ Requirements @@ -31,7 +31,7 @@ Installation .. code:: bash - pip install juju + pip3 install juju Quickstart @@ -51,10 +51,11 @@ and in the documentation. import asyncio import logging + from juju import loop from juju.model import Model - async def run(): + async def deploy(): # Create a Model instance. We need to connect our Model to a Juju api # server before we can use it. model = Model() @@ -74,9 +75,6 @@ and in the documentation. # Disconnect from the api server and cleanup. model.disconnect() - # Stop the asyncio event loop. - model.loop.stop() - def main(): # Set logging level to debug so we can see verbose output from the @@ -88,14 +86,9 @@ and in the documentation. ws_logger = logging.getLogger('websockets.protocol') ws_logger.setLevel(logging.INFO) - # Create the asyncio event loop - loop = asyncio.get_event_loop() - - # Queue up our `run()` coroutine for execution - loop.create_task(run()) - - # Start the event loop - loop.run_forever() + # Run the deploy coroutine in an asyncio event loop, using a helper + # that abstracts loop creation and teardown. + loop.run(deploy()) if __name__ == '__main__':