mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Adjust core test to avoid lingering task (#88918)
This commit is contained in:
parent
36e6a879ad
commit
ee144d34a9
@ -2034,7 +2034,8 @@ async def test_shutdown_does_not_block_on_shielded_tasks(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Ensure shutdown does not block on shielded tasks."""
|
"""Ensure shutdown does not block on shielded tasks."""
|
||||||
result = asyncio.Future()
|
result = asyncio.Future()
|
||||||
shielded_task = asyncio.shield(asyncio.sleep(10))
|
sleep_task = asyncio.ensure_future(asyncio.sleep(10))
|
||||||
|
shielded_task = asyncio.shield(sleep_task)
|
||||||
|
|
||||||
async def test_task():
|
async def test_task():
|
||||||
try:
|
try:
|
||||||
@ -2050,3 +2051,6 @@ async def test_shutdown_does_not_block_on_shielded_tasks(
|
|||||||
assert result.done()
|
assert result.done()
|
||||||
assert task.done()
|
assert task.done()
|
||||||
assert time.monotonic() - start < 0.5
|
assert time.monotonic() - start < 0.5
|
||||||
|
|
||||||
|
# Cleanup lingering task after test is done
|
||||||
|
sleep_task.cancel()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user