mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Fix parallel script execution in queued mode (#118153)
This commit is contained in:
@ -1741,3 +1741,46 @@ async def test_responses_no_response(hass: HomeAssistant) -> None:
|
||||
)
|
||||
is None
|
||||
)
|
||||
|
||||
|
||||
async def test_script_queued_mode(hass: HomeAssistant) -> None:
|
||||
"""Test calling a queued mode script called in parallel."""
|
||||
calls = 0
|
||||
|
||||
async def async_service_handler(*args, **kwargs) -> None:
|
||||
"""Service that simulates doing background I/O."""
|
||||
nonlocal calls
|
||||
calls += 1
|
||||
await asyncio.sleep(0)
|
||||
|
||||
hass.services.async_register("test", "simulated_remote", async_service_handler)
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
script.DOMAIN,
|
||||
{
|
||||
script.DOMAIN: {
|
||||
"test_main": {
|
||||
"sequence": [
|
||||
{
|
||||
"parallel": [
|
||||
{"service": "script.test_sub"},
|
||||
{"service": "script.test_sub"},
|
||||
{"service": "script.test_sub"},
|
||||
{"service": "script.test_sub"},
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"test_sub": {
|
||||
"mode": "queued",
|
||||
"sequence": [
|
||||
{"service": "test.simulated_remote"},
|
||||
],
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
await hass.services.async_call("script", "test_main", blocking=True)
|
||||
assert calls == 4
|
||||
|
Reference in New Issue
Block a user