mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Fix missing response for queued mode scripts (#141460)
This commit is contained in:
parent
93f12fb7c6
commit
63df2474a9
@ -1311,7 +1311,7 @@ class _QueuedScriptRun(_ScriptRun):
|
|||||||
|
|
||||||
lock_acquired = False
|
lock_acquired = False
|
||||||
|
|
||||||
async def async_run(self) -> None:
|
async def async_run(self) -> ScriptRunResult | None:
|
||||||
"""Run script."""
|
"""Run script."""
|
||||||
# Wait for previous run, if any, to finish by attempting to acquire the script's
|
# Wait for previous run, if any, to finish by attempting to acquire the script's
|
||||||
# shared lock. At the same time monitor if we've been told to stop.
|
# shared lock. At the same time monitor if we've been told to stop.
|
||||||
@ -1325,7 +1325,7 @@ class _QueuedScriptRun(_ScriptRun):
|
|||||||
|
|
||||||
self.lock_acquired = True
|
self.lock_acquired = True
|
||||||
# We've acquired the lock so we can go ahead and start the run.
|
# We've acquired the lock so we can go ahead and start the run.
|
||||||
await super().async_run()
|
return await super().async_run()
|
||||||
|
|
||||||
def _finish(self) -> None:
|
def _finish(self) -> None:
|
||||||
if self.lock_acquired:
|
if self.lock_acquired:
|
||||||
|
@ -5853,14 +5853,16 @@ async def test_stop_action_subscript(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(("var", "response"), [(1, "If: Then"), (2, "Testing 123")])
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("var", "response"),
|
("script_mode", "max_runs"), [("single", 1), ("parallel", 2), ("queued", 2)]
|
||||||
[(1, "If: Then"), (2, "Testing 123")],
|
|
||||||
)
|
)
|
||||||
async def test_stop_action_response_variables(
|
async def test_stop_action_response_variables(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
var: int,
|
var: int,
|
||||||
response: str,
|
response: str,
|
||||||
|
script_mode,
|
||||||
|
max_runs,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test setting stop response_variable in a subscript."""
|
"""Test setting stop response_variable in a subscript."""
|
||||||
sequence = cv.SCRIPT_SCHEMA(
|
sequence = cv.SCRIPT_SCHEMA(
|
||||||
@ -5879,7 +5881,14 @@ async def test_stop_action_response_variables(
|
|||||||
{"stop": "In the name of love", "response_variable": "output"},
|
{"stop": "In the name of love", "response_variable": "output"},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
script_obj = script.Script(hass, sequence, "Test Name", "test_domain")
|
script_obj = script.Script(
|
||||||
|
hass,
|
||||||
|
sequence,
|
||||||
|
"Test Name",
|
||||||
|
"test_domain",
|
||||||
|
script_mode=script_mode,
|
||||||
|
max_runs=max_runs,
|
||||||
|
)
|
||||||
|
|
||||||
run_vars = MappingProxyType({"var": var})
|
run_vars = MappingProxyType({"var": var})
|
||||||
result = await script_obj.async_run(run_vars, context=Context())
|
result = await script_obj.async_run(run_vars, context=Context())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user