Skip to content

Nested Futures #545

Sep 23, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

You can't pass futures between processes, so you can't create (future()) them in a parallel worker and ask them to be resolved (value()) in another. Instead, use:

fun_a <- function(x){
  a <- list()
  for(i in 1:x){
    a[[i]] <- future(Sys.sleep(5))
  }
  value(a)
}

or, equivalently using implicit future assignments syntax:

fun_a <- function(x){
  a <- listenv()
  for(i in 1:x){
    a[[i]] %<-% Sys.sleep(5)
  }
  as.list(a)
}

See also https://future.futureverse.org/articles/future-3-topologies.html

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@wfmueller29
Comment options

@HenrikBengtsson
Comment options

@wfmueller29
Comment options

Answer selected by wfmueller29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #544 on September 23, 2021 15:21.