Deferring Events: Details and Dilemmas

My comment from the draft doc to @manadart: I spent Friday playing around with workarounds [for the “lag” issue]. The juju agent won’t allow dispatch to be called from within a hook’s context. I tried to be clever and use subprocess to launch a child process that sleeps, then calls dispatch, but the Juju agent appears to be cleverer than I am. The child process fails with a complaint about being in a hook’s context.

Can you think of a better way to do this? Keeping in mind that this needs to run in a sidecar, where we don’t necessary have an init daemon like systemd.