flake: test_icloud_poll_sleep_cannot_overshoot_deadline captures other threads' time.sleep

Closed Beginner friendly
#1,034 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start with tests/test_jsonl_backup.py::test_icloud_poll_sleep_cannot_overshoot_deadline and the jsonl_backup.time usage. Run the test in isolation and inspect how monkeypatching time.sleep affects other threads. Isolate the poll loop's sleep function, then confirm the test records only [0.25] and passes in the full file.

Written by the indexing model from the issue text.

Description

Hosted CI on main d3d00b64 (run 36736602533, test (3.12)) failed:

FAILED tests/test_jsonl_backup.py::test_icloud_poll_sleep_cannot_overshoot_deadline - assert [0.25, 0.25, ...25, 0.25, ...] == [0.25]

It passes locally in isolation and with its whole file (106 passed).

Likely cause: the test does monkeypatch.setattr(jsonl_backup.time, "sleep", sleeps.append). Since jsonl_backup.time is the global time module, this patches time.sleep for the whole process. Any background thread left running by an earlier test that calls time.sleep(0.25) during this test gets recorded in sleeps.

Fix shape: inject the sleep function (or patch a module-level _sleep alias) so the test only sees the poll loop's own sleeps. Same family as #999 and #1023.

Size: XS. Routing: Codex implements, Opus reviews.

🤖 Generated with Claude Code

Dominant language
Python
Stars
9
Forks
7
Avg merge
4h 5m
Merged PRs (30d)
417

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EtanHey/brainlayer

All issues in EtanHey/brainlayer

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.