rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
197 stars 19 forks source link

Somewhat strange behavior of `future_promise()` #88

Open CrossD opened 1 year ago

CrossD commented 1 year ago

The timing of when future_promise() is resolved is somewhat counter-intuitive for me. I expect the promise at #1 to be pending, but at #2 and on should be resolved. Am I missing something? I am on Mac.

> library(future)
> library(promises)
> plan(multicore, workers=2)
> v <- future({
+   Sys.sleep(1)
+ })
> v1 <- future({
+   Sys.sleep(1)
+ })
> a <- promises::future_promise({
+   Sys.sleep(1)
+   lm(extra ~ group, data=sleep)
+ })
> a #1
<Promise [pending]>
> 
> Sys.sleep(2.1)
> value(v)
> value(v1)
> 
> Sys.sleep(0.1)
> a #2
<Promise [pending]>
> Sys.sleep(2)
> a #3
<Promise [pending]>
> 
> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.5.1

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

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

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

other attached packages:
[1] promises_1.2.0.1 future_1.29.0    colorout_1.2-2  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        codetools_0.2-18  listenv_0.8.0    
 [4] digest_0.6.29     later_1.3.0       parallelly_1.32.1
 [7] R6_2.5.1          magrittr_2.0.3    rlang_1.0.5      
[10] cli_3.4.0         tools_4.2.1       parallel_4.2.1   
[13] fastmap_1.1.0     compiler_4.2.1    globals_0.16.1