Private event loop behaves differently when executed within block
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Reproduce the two execution forms using later::create_loop(), later::later(), Sys.sleep(), and later::run_now(loop = tloop). Then trace how the private loop is serviced in each case and determine whether the difference is intended. Done means the behavior is explained and, if it is a bug, the relevant behavior is covered by a regression test.
Written by the indexing model from the issue text.
Description
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:
lateris invoked againlater::run_now(loop = tloop)is executed.
- Dominant language
- C++
- Stars
- 150
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/later
-
documentation
Difficulty 3/5 1-2 days Newbie friendliness 28/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·