Spaces:
Runtime error
Runtime error
allow parallel sessions
Browse files
app.R
CHANGED
@@ -97,8 +97,12 @@ server <- function(input, output, session) {
|
|
97 |
event_reload <- reactiveVal(val = 0)
|
98 |
observeEvent(event_reload(), ignoreNULL=FALSE, {
|
99 |
|
100 |
-
# the model is already loaded,
|
101 |
-
if (!is.null(sess$is_loaded) && sess$is_loaded)
|
|
|
|
|
|
|
|
|
102 |
|
103 |
# the model isn't loaded, this we disable the send button and
|
104 |
# show that we are loading the model
|
@@ -111,12 +115,16 @@ server <- function(input, output, session) {
|
|
111 |
cat("Started loading model ....", "\n")
|
112 |
model_loaded(sess$load_model(repo))
|
113 |
sess$is_loaded <- FALSE # not yet loaded, but loading
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
|
116 |
-
# this runs for the cases where sess$is_loaded was NULL
|
117 |
-
#
|
118 |
-
# to load the model.
|
119 |
-
|
120 |
cat("Loading model:",sess$sess$poll_process(), "\n")
|
121 |
m <- model_loaded() %>%
|
122 |
promises::then(onFulfilled = function(x) {
|
|
|
97 |
event_reload <- reactiveVal(val = 0)
|
98 |
observeEvent(event_reload(), ignoreNULL=FALSE, {
|
99 |
|
100 |
+
# the model is already loaded, we just make sure the send button is enabled
|
101 |
+
if (!is.null(sess$is_loaded) && sess$is_loaded) {
|
102 |
+
shinyjs::enable("send")
|
103 |
+
updateActionButton(inputId = "send", label = "Send")
|
104 |
+
return()
|
105 |
+
}
|
106 |
|
107 |
# the model isn't loaded, this we disable the send button and
|
108 |
# show that we are loading the model
|
|
|
115 |
cat("Started loading model ....", "\n")
|
116 |
model_loaded(sess$load_model(repo))
|
117 |
sess$is_loaded <- FALSE # not yet loaded, but loading
|
118 |
+
} else {
|
119 |
+
# the model is loading, but this is handled by another session. We should
|
120 |
+
# come back to this observer later to enable the send button once model
|
121 |
+
# is loaded.
|
122 |
+
invalidateLater(5000, session)
|
123 |
+
return()
|
124 |
}
|
125 |
|
126 |
+
# this runs for the cases where sess$is_loaded was NULL
|
127 |
+
# ie there was no model currently loading.
|
|
|
|
|
128 |
cat("Loading model:",sess$sess$poll_process(), "\n")
|
129 |
m <- model_loaded() %>%
|
130 |
promises::then(onFulfilled = function(x) {
|