mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +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
|
||||
|
||||
async def async_run(self) -> None:
|
||||
async def async_run(self) -> ScriptRunResult | None:
|
||||
"""Run script."""
|
||||
# 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.
|
||||
@ -1325,7 +1325,7 @@ class _QueuedScriptRun(_ScriptRun):
|
||||
|
||||
self.lock_acquired = True
|
||||
# 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:
|
||||
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(
|
||||
("var", "response"),
|
||||
[(1, "If: Then"), (2, "Testing 123")],
|
||||
("script_mode", "max_runs"), [("single", 1), ("parallel", 2), ("queued", 2)]
|
||||
)
|
||||
async def test_stop_action_response_variables(
|
||||
hass: HomeAssistant,
|
||||
var: int,
|
||||
response: str,
|
||||
script_mode,
|
||||
max_runs,
|
||||
) -> None:
|
||||
"""Test setting stop response_variable in a subscript."""
|
||||
sequence = cv.SCRIPT_SCHEMA(
|
||||
@ -5879,7 +5881,14 @@ async def test_stop_action_response_variables(
|
||||
{"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})
|
||||
result = await script_obj.async_run(run_vars, context=Context())
|
||||
|
Loading…
x
Reference in New Issue
Block a user