immediateCondition on delayed tasks

Aperta
#759 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r

Direzione di ricerca

Inizia eseguendo l’esempio R riproducibile con plan(multisession, workers=2) e il codice immediateCondition/immediateMessage mostrato nell’issue. Traccia il modo in cui le attività ritardate e i worker multisession accodati inoltrano le conditions, quindi verifica che i messaggi z compaiano immediatamente dopo il completamento di x o y, senza valutare z.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

documentation feature request

Describe the bug

Similar to https://github.com/futureverse/future.mirai/issues/17, I'm adapting immediateMessage as mentioned in https://github.com/futureverse/progressr/issues/176 for multisession.

It seems to work for the initial tasks, but others require an attempt to realize the value before it is printed.

Reproduce example

I'll source all of this code first. Since I'm starting two workers, the x and y expressions start immediately, and the third is intended to be queued and will process when the first two clear.

immediateMessage <- function (..., domain = NULL, appendLF = TRUE)  {
  # prepend the time, perhaps sloppy but good for demonstration
  msg <- .makeMessage(c(format(Sys.time()), " ", ...), domain = domain, appendLF = appendLF)
  call <- sys.call()
  cond <- simpleMessage(msg, call)
  class(cond) <- c(class(cond), "immediateCondition")
  message(cond)
}

library(future)
plan(multisession, workers=2)
x %<-% { immediateMessage("in x"); Sys.sleep(2); immediateMessage(paste("x ", Sys.getpid())); Sys.sleep(2); 3.14 }
y %<-% { immediateMessage("in y"); Sys.sleep(2); immediateMessage(paste("y ", Sys.getpid())); Sys.sleep(2); 2.71 }
z %<-% { immediateMessage("in z"); Sys.sleep(2); immediateMessage(paste("z ", Sys.getpid())); Sys.sleep(2); 1.62 }
x+y

If I source that block, then I see

library(future)
plan(multisession, workers=2)
x %<-% { immediateMessage("in x"); Sys.sleep(2); immediateMessage(paste("x ", Sys.getpid())); Sys.sleep(2); 3.14 }
y %<-% { immediateMessage("in y"); Sys.sleep(2); immediateMessage(paste("y ", Sys.getpid())); Sys.sleep(2); 2.71 }
z %<-% { immediateMessage("in z"); Sys.sleep(2); immediateMessage(paste("z ", Sys.getpid())); Sys.sleep(2); 1.62 }
# 2025-01-31 11:41:22 in x
# 2025-01-31 11:41:22 in y
# 2025-01-31 11:41:24 x  9219
# 2025-01-31 11:41:24 y  9218
x+y
# [1] 5.85

As I said in the other issue, the fact that x+y shows after the messages indicates that some messages are immediate.

Once that's done, I pause for a moment and see that the z messages do not appear. If I then manually type z in the console, I immediately see:

z; Sys.time()
# 2025-01-31 11:41:26 in z
# 2025-01-31 11:41:28 z  9219
# [1] 1.62
# [1] "2025-01-31 11:42:25 EST"

It is clear to me that the execution was in fact scheduled immediately after one of x or y completed, but the messages themselves did not appear until I evaluated z (and the 11:42:25 indicates the time between when I pasted here, then typed some comments, and then went back to the console, demonstrating that the z code executed correctly on time).

A reproducible example using R code.

Please format your inline code and code blocks using Markdown (https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).

Expected behavior

I expect the z messages would appear on the console immediately after one of the x or y tasks is complete.

Session information

sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 15.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] future.mirai_0.2.2 future_1.34.0      r2_0.12.0         

loaded via a namespace (and not attached):
 [1] mirai_2.0.1       digest_0.6.37     codetools_0.2-20  fastmap_1.2.0     xfun_0.49         nanonext_1.5.0    knitr_1.49        parallel_4.3.3    htmltools_0.5.8.1
[10] rmarkdown_2.29    cli_3.6.3         parallelly_1.40.1 compiler_4.3.3    globals_0.16.3    tools_4.3.3       listenv_0.9.1     clipr_0.8.0       evaluate_1.0.1   
[19] rlang_1.1.5      
Lingua principale
R
Stelle
1k
Fork
93
Merge medio
2g 4h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di futureverse/future

Tutte le issue di futureverse/future

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.