admin管理员组

文章数量:1204633

Goal

I have a teacher UI in my shiny app where a teacher can select any student ID from a selectizeInput. Based on the current student info in the Firestore database, data is fetched and a ggiraph plot is drawn. The points in the plot are clickable that launch modals containing further information.

Challenge

I expect 10-15 "teacher" users simultaneously using the app. Each student plot takes a minimum of 2 secs. I can bindCache them. But, regular shiny usage can slow the user experience significantly with simultaneous users. So, I want to draw student plots in a separate R session. My understanding is that it would create 1 main app session and 1 additional R session per user for drawing the plot as per my {crew} code.

Errors

Although the async code via {crew} works mostly, I get errors when I test 5-8 simultaneous users. The errors are:

Warning: Error in attributes<-: dims [product 5] do not match the length of object [1]
63: query_status
62: mirai::status
61: <Anonymous>
57: daemons_info
54: private$.launcher$scale
53: .subset2(self, "scale")
52: controller()$pop
51: observe
50: <observer>
3: runApp
2: print.shiny.appobj
1: <Anonymous>

Warning: Error in attributes<-: dims [product 5] do not match the length of object [1]
59: query_status
58: mirai::status
57: <Anonymous>
53: daemons_info
52: controller()$client$summary
51: observe
50: <observer>
3: runApp
2: print.shiny.appobj
1: <Anonymous>

Warning: Error in attributes<-: dims [product 5] do not match the length of object [1]
63: query_status
62: mirai::status
61: <Anonymous>
57: daemons_info
55: self$tally
54: private$.launcher$scale
53: .subset2(self, "scale")
52: controller()$pop
51: observe
50: <observer>
3: runApp
2: print.shiny.appobj
1: <Anonymous>

These errors disconnect the app for some users, not all. So, I don't understand what is wrong with my code.

Example Code

I have created an example repo here: The {crew} code is in the plot module which is shown below:

collection_paths_e <- c("assign1", "assign2", "assign3",
                        "done1", "done2", "done3")

mod_plot_ui <- function(id){
  ns <- NS(id)
  tagList(
    textOutput(ns("status")),
    girafeOutput(ns("student_progress"))
  )
}


mod_plot_server <- function(id, accessToken, uid, this_email,
                                             parent_session) {
  moduleServer(id, function(input, output, session) {
    ns <- session$ns

    # Initialize cache manager
    cache_manager <- PlotCache$new()

    event_names_list_stu <- reactivePoll(
      10000,
      session,
      checkFunc = function() {
        get_all_event_names_for_a_student(collection_paths_e, uid(), accessToken())
      },
      valueFunc = function() {
        get_all_event_names_for_a_student(collection_paths_e, uid(), accessToken())
      }
    )

    # Create a hash of the current data
    current_data_hash <- reactive({
      req(event_names_list_stu())
      digest::digest(event_names_list_stu())
    })

    status_message <- function(n) {
      if (n > 0) {
        paste(format(Sys.time()), "tasks in progress ⏳ :", n)
      } else {
        paste(format(Sys.time()), "All tasks completed 

本文标签: rErrors with crew when doing async programming in shinyStack Overflow