Let's define this function and event loop:
fn <- function() print(Sys.time())
tloop <- later::create_loop()
If I execute a block of code like this, then fn gets exxecuted:
> {print(Sys.time()); later::later(fn, delay = 2, loop = tloop); Sys.sleep(5)}
[1] "2023-05-14 11:19:17 UTC"
[1] "2023-05-14 11:19:23 UTC"
But if I execute line by line (important!), I get this:
> print(Sys.time())
[1] "2023-05-14 11:21:16 UTC"
> later::later(fn, delay = 2, loop = tloop)
> Sys.sleep(5)
Why does the fn execute in first case, but not in the second case? Is this by design, or a bug?
In the second case, fn would be execueted only if 2 seconds pass and either:
later is invoked again
later::run_now(loop = tloop) is executed.
Let's define this function and event loop:
If I execute a block of code like this, then
fngets exxecuted:But if I execute line by line (important!), I get this:
Why does the
fnexecute in first case, but not in the second case? Is this by design, or a bug?In the second case,
fnwould be execueted only if 2 seconds pass and either:lateris invoked againlater::run_now(loop = tloop)is executed.