From 3c480a7be0524dbcaa30f2a2d6165069df813e9c Mon Sep 17 00:00:00 2001 From: m7pr Date: Wed, 10 Jul 2024 14:57:37 +0200 Subject: [PATCH] lockfile_status_tracker --- R/init.R | 3 +-- R/teal_lockfile.R | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/R/init.R b/R/init.R index 144a081f0c..ec51fde04f 100644 --- a/R/init.R +++ b/R/init.R @@ -231,8 +231,7 @@ init <- function(data, if (!is.null(landing_module)) { do.call(landing_module$server, c(list(id = "landing_module_shiny_id"), landing_module$server_args)) } - session$userData$lockfile_process <- process - reactivePoll(1000, session, checkFunc = lockfile_status, valueFunc = function() {}) + lockfile_status_tracker(process) srv_teal_with_splash(id = id, data = data, modules = modules, filter = deep_copy_filter(filter)) } ) diff --git a/R/teal_lockfile.R b/R/teal_lockfile.R index e02cd70c3e..89e98d6361 100644 --- a/R/teal_lockfile.R +++ b/R/teal_lockfile.R @@ -96,18 +96,23 @@ teal_lockfile_downloadhandler <- function() { ) } -lockfile_status <- function() { - process <- session$userData$lockfile_process - if (!process$is_alive()) { - renv_logs <- process$read_output() - - if (any(grepl("Lockfile written", renv_logs))) { - logger::log_trace("lockfile created successfully.") - } else { - logger::log_trace("lockfile created with issues.") - } - TRUE +lockfile_status <- function(process) { + renv_logs <- process$read_output() + if (any(grepl("Lockfile written", renv_logs))) { + logger::log_trace("lockfile created successfully.") } else { - FALSE + logger::log_trace("lockfile created with issues.") } } + +lockfile_status_tracker <- function(process) { + timer <- reactiveTimer(1000) + + tracker <- observe({ + timer() + if (!process$is_alive()) { + lockfile_status(process) + tracker$destroy() + } + }) +}