Just wanted to share my progress on scripting with the juju library. Initially, It took me a moment to wrap my head around (mostly due to my inexperience with asynchronous programming) how to interface to the juju library, and write a simple script that exits cleanly (without spewing tracebacks http://paste.ubuntu.com/23678912/). I iterated on this for some time yesterday, then came back to it for a few moments this morning. Combining a few of my ideas from yesterday, I ended finding a combination that worked for what I was after [1]. This solution requires a few critical pieces to all exist, in order to function as I was intending. The key pieces needed to make this work correctly for me; use aiohttp context while accessing juju lib objects [2] (this seems mandatory in order to get a response back from juju lib), use signal handlers that cancel the remaining tasks correctly [3], call 'sys.exit(1)' after closing the loop [4]. After pulling these pieces together, I ended up with something that I think I can work with moving forward.
Hopefully this helps others get things kicked off with lib juju a bit faster! Happy holidays all! ~James [1] https://gist.github.com/jamesbeedy/18fc2c910716cd92343bc876af8c7bb6 [2] https://gist.github.com/jamesbeedy/18fc2c910716cd92343bc876af8c7bb6#file-model_connect-py-L31 [3] https://gist.github.com/jamesbeedy/18fc2c910716cd92343bc876af8c7bb6#file-model_connect-py-L50,L51 [4] https://gist.github.com/jamesbeedy/18fc2c910716cd92343bc876af8c7bb6#file-model_connect-py-L60
-- Juju-dev mailing list Juju-dev@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju-dev