Repository navigation
Conversation
The service handler waits on a future while the function runs in a separate task, so cancelling the caller (e.g. a stopped or restarted script) no longer reached the function. The manager now records the call task in DispatchData.call_task and the service handler cancels it, as the old await on the task did.
This was referenced Nov 18, 2026
Contributor
Author
|
FYI: the PR removing the legacy decorator subsystem is ready. It depends on this one, so I'll open it once this is merged. Happy to make any changes needed here. @craigbarratt a lot has piled up since 2.1.1. How about releasing 2.2.0 after this is merged, and removing the legacy subsystem in the next release? That way users still have |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Route
@servicethrough the decorator managerFollow-up to #870.
@servicenow goes through the same DecoratorManager pipeline as the trigger decorators, so it no longer depends onTRIGGER_KWARGS.Changes
ServiceDecoratoris now aTriggerDecorator+CallResultHandlerDecorator(like@webhook_handler). The function result is returned through a future.await taskdid: the manager records the call task inDispatchData.call_task, and the service handler cancels it.FunctionDecoratorManager._call()callshandle_call_canceledwhen a running call is cancelled (e.g. by@task_unique). This also fixes@webhook_handler, which waited for its timeout and now returns 503 immediately.@servicetests are moved totests/decorators/test_service.py.Breaking changes
@state_active,@time_activeand@task_uniquenow apply to service calls.None, gives{}when a response is requested, like HA scripts. Previously HA core raised "expected a dictionary".TypeError, unless the name was inTRIGGER_KWARGS.HomeAssistantError. Previously it was only logged and the caller saw success.pyscript_running(logbook) and runs in a childContext.Notes
@time_active(hold_off_send_last=True), a service call suppressed during the hold-off window is answered right away as skipped, but the function still runs with its data when the window ends (documented).@servicebeing a trigger, it acceptskwargs=like other triggers; this is not documented.Question
@craigbarratt,
#4can stop existing automations that call a failing service. I think failing the call is the correct behavior, but it's easy to revert if you'd rather keep the old one (log only, report success). It's a separate commit.