From 4bb8fe6679d4829caf3f4dc67602745ac1f17de8 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Wed, 5 Jun 2024 08:23:15 -0500 Subject: [PATCH] ensure that tempfile is removed if `expr` fails --- R/syrup.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/syrup.R b/R/syrup.R index db1646f..0efec72 100644 --- a/R/syrup.R +++ b/R/syrup.R @@ -79,6 +79,7 @@ syrup <- function(expr, interval = .5, peak = FALSE, env = caller_env()) { # communicate with `sesh` through existence of a tempfile: keep_going_file <- tempfile() file.create(keep_going_file) + withr::defer(if (file.exists(keep_going_file)) file.remove(keep_going_file)) # regularly take snapshots of memory usage of R sessions sesh$call(