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

Xiaomi Aqara: Don't call async from sync #13057

Merged
merged 1 commit into from Mar 10, 2018
Merged

Xiaomi Aqara: Don't call async from sync #13057

merged 1 commit into from Mar 10, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Mar 10, 2018

Description:

Call sync version of register.

Found by @arsaboo after running asyncio in debug mode via hass.loop.set_debug(True):

Error during setup of component xiaomi_aqara
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 145, in _async_setup_component
    component.setup, hass, processed_config)
  File "/usr/lib/python3.6/asyncio/futures.py", line 332, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/xiaomi_aqara.py", line 187, in setup
    schema=_add_gateway_to_schema(xiaomi, SERVICE_SCHEMA_PLAY_RINGTONE))
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 861, in async_register
    {ATTR_DOMAIN: domain, ATTR_SERVICE: service}
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 409, in async_fire
    self._hass.async_add_job(func, event)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/core.py", line 220, in async_add_job
    self.loop.call_soon(target, *args)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 576, in call_soon
    self._check_thread()
  File "/usr/lib/python3.6/asyncio/base_events.py", line 615, in _check_thread
    "Non-thread-safe operation invoked on an event loop other "
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one

@OttoWinter
Copy link
Member

Oh, that option is very handy! Good to know 👍 (I'll put it on my staging server to hopefully catch a few more of these)

@balloob
Copy link
Member Author

balloob commented Mar 10, 2018

@OttoWinter went 1 step further and enabled it for all our tests #13058

@balloob balloob merged commit f01b5b0 into dev Mar 10, 2018
@balloob balloob deleted the xiaomi-aqara-services branch March 10, 2018 18:02
balloob added a commit that referenced this pull request Mar 10, 2018
@balloob balloob mentioned this pull request Mar 10, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants