immediateCondition on delayed tasks
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- r
调研方向
首先运行可复现的 R 示例,使用 plan(multisession, workers=2) 以及 issue 中所示的 immediateCondition/immediateMessage 代码。跟踪延迟任务和排队中的 multisession worker 如何转发 conditions,然后验证 z 消息会在 x 或 y 完成后立即出现,而不会对 z 求值。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- R
- 星标
- 1k
- 派生
- 93
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
futureverse/future 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
futureverse/future#852 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 35/100
futureverse/future#849 ·
-
bug
难度 4/5 3-5 天 新手友好度 48/100
futureverse/future#833 ·
-
feature/resources RNG
难度 5/5 一周以上 新手友好度 35/100
futureverse/future#832 ·
-
RNG
难度 5/5 一周以上 新手友好度 38/100
futureverse/future#831 · 1 条评论 ·
查看 futureverse/future 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 88/100
nf-core/provenancereport#75 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 1/5 1 小时以内 新手友好度 72/100
garner-code/PsyR#80 ·