Skip to content

Fix race between script delay and turn_off#16923

Merged
bachya merged 1 commit intohome-assistant:devfrom
amelchio:script-listener-remove-race
Sep 28, 2018
Merged

Fix race between script delay and turn_off#16923
bachya merged 1 commit intohome-assistant:devfrom
amelchio:script-listener-remove-race

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

Description:

We already had a helper method that will only unsubscribe existing listeners; however, it was not used consistently.

2018-09-27 18:16:01 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback <function async_track_point_in_utc_time.<locals>.point_in_time_listener at 0x10c2312f0>
Traceback (most recent call last):
  File "uvloop/cbhandles.pyx", line 66, in uvloop.loop.Handle._run
  File "/Users/am/home-assistant/homeassistant/helpers/event.py", line 210, in point_in_time_listener
    hass.async_run_job(action, now)
  File "/Users/am/home-assistant/homeassistant/core.py", line 327, in async_run_job
    target(*args)
  File "/Users/am/home-assistant/homeassistant/helpers/script.py", line 98, in async_script_delay
    self._async_listener.remove(unsub)
ValueError: list.remove(x): x not in list

Example entry for configuration.yaml (if applicable):

automation:
  trigger:
    - platform: state
      entity_id: script.sleep
  action:
    - service: script.toggle
      entity_id: script.sleep

script:
  sleep:
    sequence:
      - delay:
          milliseconds: 1

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@amelchio amelchio requested a review from a team as a code owner September 27, 2018 17:42
@homeassistant homeassistant added cla-signed core small-pr PRs with less than 30 lines. labels Sep 27, 2018
@ghost ghost assigned amelchio Sep 27, 2018
@ghost ghost added the in progress label Sep 27, 2018
@amelchio amelchio removed their assignment Sep 27, 2018
@bachya bachya merged commit 720b05c into home-assistant:dev Sep 28, 2018
@ghost ghost removed the in progress label Sep 28, 2018
@bachya
Copy link
Copy Markdown
Contributor

bachya commented Sep 28, 2018

Thanks! 😎

@balloob balloob mentioned this pull request Oct 12, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Feb 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed core small-pr PRs with less than 30 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants