Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid state #16558

Merged
merged 3 commits into from
Sep 11, 2018
Merged

Fix invalid state #16558

merged 3 commits into from
Sep 11, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Sep 11, 2018

Description:

In #15674 we started checking if a service was done by comparing context. This was an incorrect assumption as context has to propagate. So when we added that in #16415, the service executed handler could be called twice.

This fixes it by restoring unique call IDs for service calls.

Related issue (if applicable): fixes #16544

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

If the code does not interact with devices:

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

@balloob balloob added this to the 0.78.0 milestone Sep 11, 2018
@balloob balloob requested a review from a team as a code owner September 11, 2018 11:17
@ghost ghost assigned balloob Sep 11, 2018
@ghost ghost added the in progress label Sep 11, 2018
@@ -1042,10 +1043,13 @@ def call(self, domain: str, service: str,
This method is a coroutine.
"""
context = context or Context()
self._call_id += 1
call_id = self._call_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use uuid4. Because we can restore the context object and the caller ID is not equal anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the call ID is not part of the context, it's only used by the service registry during run time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using uuid 4 now.

@balloob balloob merged commit 06af764 into dev Sep 11, 2018
@ghost ghost removed the in progress label Sep 11, 2018
@balloob balloob deleted the fix-invalid-state branch September 11, 2018 19:40
balloob added a commit that referenced this pull request Sep 11, 2018
* Fix invalid state

* Make slightly more efficient in unsubscribing

* Use uuid4"
@balloob balloob mentioned this pull request Sep 17, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.78.0b0 asyncio.base_futures.InvalidStateError: invalid state
3 participants