Skip to content

Commit 53f784b

Browse files
committed
test: Properly await for service task
Otherwise pytest will print errors about a dangling task still running. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent acd177a commit 53f784b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/test_bidirectional.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ async def service(handle: Bidirectional.Handle[str, int]) -> None:
1818
num = await handle.receive()
1919
if num is None:
2020
break
21+
if num == 42:
22+
break
2123
if num >= 0:
2224
await handle.send("positive")
2325
else:
2426
await handle.send("negative")
2527

26-
asyncio.create_task(
28+
service_task = asyncio.create_task(
2729
service(req_resp.service_handle),
2830
)
2931

@@ -36,3 +38,6 @@ async def service(handle: Bidirectional.Handle[str, int]) -> None:
3638
assert ret == "negative"
3739
else:
3840
assert ret == "positive"
41+
42+
await client_handle.send(42) # Stop the service task
43+
await service_task

0 commit comments

Comments
 (0)