Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tests/shutdown_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@

import ezmsg.core as ez

STARTED = threading.Event()


class BlockingDiskIO(ez.Unit):
@ez.task
async def blocked_read(self) -> None:
# Cross-platform "hung disk I/O" simulation.
STARTED.set()
event = threading.Event()
self._event = event
await asyncio.shield(asyncio.to_thread(event.wait))
Expand All @@ -21,6 +24,7 @@ async def blocked_read(self) -> None:
class BlockingSocket(ez.Unit):
@ez.task
async def blocked_recv(self) -> None:
STARTED.set()
sock_r, sock_w = socket.socketpair()
sock_r.setblocking(True)
sock_w.setblocking(True)
Expand All @@ -33,6 +37,7 @@ async def blocked_recv(self) -> None:
class ExplodeOnCancel(ez.Unit):
@ez.task
async def explode(self) -> None:
STARTED.set()
try:
while True:
await asyncio.sleep(1.0)
Expand All @@ -43,6 +48,7 @@ async def explode(self) -> None:
class StubbornTask(ez.Unit):
@ez.task
async def ignore_cancel(self) -> None:
STARTED.set()
while True:
try:
await asyncio.sleep(1.0)
Expand Down Expand Up @@ -84,7 +90,7 @@ def _emit_ready() -> None:

def _watch_ready() -> None:
while not done.is_set():
if runner.running:
if runner.running and STARTED.is_set():
_emit_ready()
return
time.sleep(0.01)
Expand Down
Loading