How to avoid "detritus in the temp directory" R CMD check on Windows #105
-
| Consider the following  library(mirai)
message("Reset")
mirai::daemons(0)
print(mirai::daemons())
message("Launch two workers")
mirai::daemons(2)
print(mirai::daemons())
message("Reset")
mirai::daemons(0)
print(mirai::daemons())
Sys.sleep(5)When running  I'm pretty certain those  I've created a minimal R package that illustrates this problem via GitHub Actions available at https://github.com/HenrikBengtsson/teeny/tree/package/mirai. How can I make sure that all background R processes that mirai launches are properly shut down before I exit my test script? | 
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 15 replies
-
| Maybe it's the dispatcher process that leaves this behind, or is not shut down.  When using  library(mirai)
message("Reset")
mirai::daemons(0)
print(mirai::daemons())
message("Launch two workers")
mirai::daemons(2, dispatcher = FALSE)
print(mirai::daemons())
message("Reset")
mirai::daemons(0)
print(mirai::daemons())
Sys.sleep(5) | 
Beta Was this translation helpful? Give feedback.
-
| 
 Just tried, and, yes, the "detritus in the temp directory" NOTE is no longer there on MS Windows, cf. On a side note, and unrelated to this topic, this resulted in the following macOS (only) error: That could be specific to GitHub Actions. | 
Beta Was this translation helpful? Give feedback.
-
| 
 From the documentation of  
 From my perspective, this can only help  | 
Beta Was this translation helpful? Give feedback.
I moved a dispatcher test to run on Windows and it is not showing the detritus issue. On Github, R-universe or indeed Win-builder. That test does happen to use
daemons(NULL)though.daemons(NULL)sends an exit signal to the daemons, so those should now exit first, before the host and dispatcher processes are torn down.