Skip to content

Commit 8a9ad34

Browse files
committed
tests: sync shutdown READY signal with task startup
1 parent 67fac39 commit 8a9ad34

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/shutdown_runner.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
import ezmsg.core as ez
1010

11+
STARTED = threading.Event()
12+
1113

1214
class BlockingDiskIO(ez.Unit):
1315
@ez.task
1416
async def blocked_read(self) -> None:
1517
# Cross-platform "hung disk I/O" simulation.
18+
STARTED.set()
1619
event = threading.Event()
1720
self._event = event
1821
await asyncio.shield(asyncio.to_thread(event.wait))
@@ -21,6 +24,7 @@ async def blocked_read(self) -> None:
2124
class BlockingSocket(ez.Unit):
2225
@ez.task
2326
async def blocked_recv(self) -> None:
27+
STARTED.set()
2428
sock_r, sock_w = socket.socketpair()
2529
sock_r.setblocking(True)
2630
sock_w.setblocking(True)
@@ -33,6 +37,7 @@ async def blocked_recv(self) -> None:
3337
class ExplodeOnCancel(ez.Unit):
3438
@ez.task
3539
async def explode(self) -> None:
40+
STARTED.set()
3641
try:
3742
while True:
3843
await asyncio.sleep(1.0)
@@ -43,6 +48,7 @@ async def explode(self) -> None:
4348
class StubbornTask(ez.Unit):
4449
@ez.task
4550
async def ignore_cancel(self) -> None:
51+
STARTED.set()
4652
while True:
4753
try:
4854
await asyncio.sleep(1.0)
@@ -84,7 +90,7 @@ def _emit_ready() -> None:
8490

8591
def _watch_ready() -> None:
8692
while not done.is_set():
87-
if runner.running:
93+
if runner.running and STARTED.is_set():
8894
_emit_ready()
8995
return
9096
time.sleep(0.01)

0 commit comments

Comments
 (0)