Hi Merlijn On Thu, Feb 18, 2016 at 10:15 AM, Merlijn Sebrechts < merlijn.sebrec...@gmail.com> wrote:
> > Thank you for your response, we did not realize this was the case, this > might come in handy! > > Now to get some clarification: If we have the following code: > > if some-condition: > @when(...) > def some_function(...): > ... > > and `some-condition` changes after the initial registration of handlers. > Will `some_function` be registered, or will this only happen during the > next hook run? > A new process is invoked for each 'run' of a hook, and so from the perspective of the Python script/program it is starting anew each time for each hook invocation (i.e. there is no 'server' handling hooks). Thus the @when(...) are registered every time a hook is called. So, if you register them dynamically, then they could be different during each hook invocation. Whether this is a good idea is debatable as the hooks registered would be determined by the state of the system as a whole which might make it tricky to debug, test, and reason about. > > The possible values for package-names are not known during build time. We > do know that _all_ queued packages have to be installed. Would it be > possible to have an `apt.installed.all` state? > Well, your own script sets the states, so yes; but I don't know enough about your use case to advise on that - I was more commenting on what's possible in Python. Cheers Alex. -- Alex Kavanagh - Software Engineer Cloud Dev Ops - Solutions & Product Engineering - Canonical Ltd
-- Juju mailing list Juju@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju