File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 129129 timeout <- Inf
130130 timeout
131131}
132+
133+ # # This function walks through a nested list and attempts to trigger
134+ # # loading of any encountered S4 class definitions using getClassDef().
135+ # #
136+ # # Limitations:
137+ # # - It does NOT guarantee that all required packages will be loaded,
138+ # # because S4 objects may be hidden in attributes, environments, or other
139+ # # non-list structures that are not traversed here.
140+ .autoload_s4_classes <- function (obj ) {
141+ seen <- character ()
142+ recurse <- function (x ) {
143+ if (isS4(x )) {
144+ cl <- class(x )
145+ if (! cl %in% seen ) {
146+ seen <<- c(seen , cl )
147+ methods :: getClassDef(cl )
148+ }
149+ } else if (is.list(x )) {
150+ lapply(x , recurse )
151+ }
152+ }
153+ recurse(obj )
154+ }
Original file line number Diff line number Diff line change 311311
312312 t1 <- proc.time()
313313 value <- tryCatch({
314+ # # Lazy loading causes some packages fail to load in the worker
315+ # # environment. This works in 99% cases (see function comments).
316+ .autoload_s4_classes(msg $ data $ args $ X )
314317 do.call(msg $ data $ fun , msg $ data $ args )
315318 }, error = function (e ) {
316319 # # return as 'list()' because msg$fun has lapply semantics
You can’t perform that action at this time.
0 commit comments