@@ -166,7 +166,7 @@ CHELSA_process <- function(
166166 c1 <- snow :: makeSOCKcluster(n_cores )
167167 on.exit(try(snow :: stopCluster(c1 ), silent = TRUE ), add = TRUE )
168168 future :: plan(" future::cluster" , workers = c1 , gc = TRUE )
169- on.exit (future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
169+ withr :: defer (future :: plan(" future::sequential" , gc = TRUE ))
170170 }
171171
172172 CHELSA_Data_Checked <- CHELSA_Data %> %
@@ -232,7 +232,7 @@ CHELSA_process <- function(
232232 c1 <- snow :: makeSOCKcluster(n_cores )
233233 on.exit(try(snow :: stopCluster(c1 ), silent = TRUE ), add = TRUE )
234234 future :: plan(" future::cluster" , workers = c1 , gc = TRUE )
235- on.exit (future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
235+ withr :: defer (future :: plan(" future::sequential" , gc = TRUE ))
236236 }
237237
238238
@@ -371,7 +371,7 @@ CHELSA_process <- function(
371371 c1 <- snow :: makeSOCKcluster(n_cores )
372372 on.exit(try(snow :: stopCluster(c1 ), silent = TRUE ), add = TRUE )
373373 future :: plan(" future::cluster" , workers = c1 , gc = TRUE )
374- on.exit (future :: plan(" future::sequential" , gc = TRUE ), add = TRUE )
374+ withr :: defer (future :: plan(" future::sequential" , gc = TRUE ))
375375 }
376376
377377 # String to be matched to extract variable names
0 commit comments