MCPcopy
hub / github.com/python-trio/trio / test_Event

Function test_Event

src/trio/_tests/test_sync.py:17–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16
17async def test_Event() -> None:
18 e = Event()
19 assert not e.is_set()
20 assert e.statistics().tasks_waiting == 0
21
22 with pytest.warns(
23 DeprecationWarning,
24 match=r"trio\.Event\.__bool__ is deprecated since Trio 0\.31\.0; use trio\.Event\.is_set instead \(https://github.com/python-trio/trio/issues/3238\)",
25 ):
26 e.__bool__()
27
28 e.set()
29 assert e.is_set()
30 with assert_checkpoints():
31 await e.wait()
32
33 e = Event()
34
35 record = []
36
37 async def child() -> None:
38 record.append("sleeping")
39 await e.wait()
40 record.append("woken")
41
42 async with _core.open_nursery() as nursery:
43 nursery.start_soon(child)
44 nursery.start_soon(child)
45 await wait_all_tasks_blocked()
46 assert record == ["sleeping", "sleeping"]
47 assert e.statistics().tasks_waiting == 2
48 e.set()
49 await wait_all_tasks_blocked()
50 assert record == ["sleeping", "sleeping", "woken", "woken"]
51
52
53async def test_CapacityLimiter() -> None:

Callers

nothing calls this directly

Calls 9

is_setMethod · 0.95
statisticsMethod · 0.95
__bool__Method · 0.95
setMethod · 0.95
waitMethod · 0.95
EventClass · 0.85
assert_checkpointsFunction · 0.85
wait_all_tasks_blockedFunction · 0.85
start_soonMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…