From ebb8fc065d6dfa9126a9a15d3d64436f8593310d Mon Sep 17 00:00:00 2001 From: elkowar <5300871+elkowar@users.noreply.github.com> Date: Sun, 31 Jan 2021 16:20:19 +0100 Subject: [PATCH] Run poll-vars immediately when starting (fixes #98) --- src/script_var_handler.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/script_var_handler.rs b/src/script_var_handler.rs index 53b4e4d..949b580 100644 --- a/src/script_var_handler.rs +++ b/src/script_var_handler.rs @@ -135,6 +135,11 @@ impl PollVarHandler { self.poll_handles.insert(var.name.clone(), cancellation_token.clone()); let evt_send = self.evt_send.clone(); tokio::spawn(async move { + let result: Result<_> = try { + evt_send.send(app::DaemonCommand::UpdateVars(vec![(var.name.clone(), var.run_once()?)]))?; + }; + crate::print_result_err!("while running script-var command", &result); + crate::loop_select_exiting! { _ = cancellation_token.cancelled() => break, _ = tokio::time::sleep(var.interval) => {