Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jul 1, 2024
1 parent 739ccd5 commit be456ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions notes-to-self/loopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
async def loopy():
try:
while True:
time.sleep( # noqa: ASYNC101 # synchronous sleep to avoid maxing out CPU
time.sleep( # synchronous sleep to avoid maxing out CPU
0.01
)
await trio.sleep(0)
await trio.lowlevel.checkpoint()
except KeyboardInterrupt:
print("KI!")

Expand Down
2 changes: 1 addition & 1 deletion notes-to-self/schedule-timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async def reschedule_loop(depth):
global LOOPS
while RUNNING:
LOOPS += 1
await trio.sleep(0)
await trio.lowlevel.checkpoint()
# await trio.lowlevel.cancel_shielded_checkpoint()
else:
await reschedule_loop(depth - 1)
Expand Down
12 changes: 6 additions & 6 deletions src/trio/_core/_tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def done_callback(outcome: Outcome[T]) -> None:

def test_guest_trivial() -> None:
async def trio_return(in_host: InHost) -> str:
await trio.sleep(0)
await trio.lowlevel.checkpoint()
return "ok"

assert trivial_guest_run(trio_return) == "ok"
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_guest_is_initialized_when_start_returns() -> None:

async def trio_main(in_host: InHost) -> str:
record.append("main task ran")
await trio.sleep(0)
await trio.lowlevel.checkpoint()
assert trio.lowlevel.current_trio_token() is trio_token
return "ok"

Expand All @@ -164,7 +164,7 @@ def after_start() -> None:
@trio.lowlevel.spawn_system_task
async def early_task() -> None:
record.append("system task ran")
await trio.sleep(0)
await trio.lowlevel.checkpoint()

res = trivial_guest_run(trio_main, in_host_after_start=after_start)
assert res == "ok"
Expand Down Expand Up @@ -396,7 +396,7 @@ def do_abandoned_guest_run() -> None:
async def abandoned_main(in_host: InHost) -> None:
in_host(lambda: 1 / 0)
while True:
await trio.sleep(0)
await trio.lowlevel.checkpoint()

with pytest.raises(ZeroDivisionError):
trivial_guest_run(abandoned_main)
Expand Down Expand Up @@ -472,7 +472,7 @@ async def trio_main() -> str:

# Make sure we have at least one tick where we don't need to go into
# the thread
await trio.sleep(0)
await trio.lowlevel.checkpoint()

from_trio.put_nowait(0)

Expand Down Expand Up @@ -540,7 +540,7 @@ async def crash_in_run_loop(in_host: InHost) -> None:

async def crash_in_io(in_host: InHost) -> None:
m.setattr("trio._core._run.TheIOManager.get_events", None)
await trio.sleep(0)
await trio.lowlevel.checkpoint()

with pytest.raises(trio.TrioInternalError):
trivial_guest_run(crash_in_io)
Expand Down
2 changes: 1 addition & 1 deletion src/trio/_tests/test_scheduler_determinism.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async def scheduler_trace() -> tuple[tuple[str, int], ...]:
async def tracer(name: str) -> None:
for i in range(50):
trace.append((name, i))
await trio.sleep(0)
await trio.lowlevel.checkpoint()

async with trio.open_nursery() as nursery:
for i in range(5):
Expand Down

0 comments on commit be456ae

Please sign in to comment.