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

Sonos - Detected blocking call to putrequest inside the event loop: soco.uid, ip_addr, "manual zone scan" #93715

Closed
mkoval opened this issue May 28, 2023 · 4 comments

Comments

@mkoval
Copy link

mkoval commented May 28, 2023

The problem

I receive the following warning when restarting Home Assistant with the Sonos integration enabled:

Detected blocking call to putrequest inside the event loop. This is causing stability issues. Please report issue for sonos doing blocking calls at homeassistant/components/sonos/init.py, line 424: soco.uid, ip_addr, "manual zone scan"

I am debugging a network issue, so it's not too surprising that the connection failed. I am mostly reporting this issue because the log message asked me to. 😂

What version of Home Assistant Core has the issue?

core-2023.5.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sonos

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sonos/

Diagnostics information

No response

Example YAML snippet

sonos:
  media_player:
    advertise_addr: 192.168.1.20
    hosts:
    - 192.168.3.233
    - 192.168.3.250

Anything in the logs that might be useful for us?

Logger: homeassistant.util.async_
Source: util/async_.py:159
First occurred: 12:17:26 PM (1 occurrences)
Last logged: 12:17:26 PM

Detected blocking call to putrequest inside the event loop. This is causing stability issues. Please report issue for sonos doing blocking calls at homeassistant/components/sonos/__init__.py, line 424: soco.uid, ip_addr, "manual zone scan"
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 163, in async_setup_entry
    await manager.setup_platforms_and_discovery()
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 547, in setup_platforms_and_discovery
    await self.async_poll_manual_hosts()
  File "/usr/src/homeassistant/homeassistant/components/sonos/__init__.py", line 424, in async_poll_manual_hosts
    soco.uid, ip_addr, "manual zone scan"
  File "/usr/local/lib/python3.10/site-packages/soco/core.py", line 422, in uid
    self.zone_group_state.poll(self)
  File "/usr/local/lib/python3.10/site-packages/soco/core.py", line 1559, in zone_group_state
    zgs = self.zone_group_states.get(self.household_id)
  File "/usr/local/lib/python3.10/site-packages/soco/core.py", line 444, in household_id
    self._household_id = self.deviceProperties.GetHouseholdID()[
  File "/usr/local/lib/python3.10/site-packages/soco/services.py", line 206, in _dispatcher
    return self.send_command(action, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/soco/services.py", line 473, in send_command
    args = self.compose_args(action, kwargs)
  File "/usr/local/lib/python3.10/site-packages/soco/services.py", line 333, in compose_args
    for action in self.actions:
  File "/usr/local/lib/python3.10/site-packages/soco/services.py", line 675, in actions
    self._actions = list(self.iter_actions())
  File "/usr/local/lib/python3.10/site-packages/soco/services.py", line 701, in iter_actions
    scpd_body = requests.get(self.base_url + self.scpd_url, timeout=10).content
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1294, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 219, in putrequest
    return _HTTPConnection.putrequest(self, method, url, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 159, in protected_loop_func
    check_loop(func, strict=strict)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 146, in check_loop
    raise RuntimeError(
RuntimeError: Blocking calls must be done in the executor or a separate thread; Use `await hass.async_add_executor_job()`; at homeassistant/components/sonos/__init__.py, line 424: soco.uid, ip_addr, "manual zone scan"
Logger: homeassistant.components.sonos
Source: components/sonos/__init__.py:163
Integration: Sonos ([documentation](https://www.home-assistant.io/integrations/sonos), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sonos%22))
First occurred: 12:17:16 PM (2 occurrences)
Last logged: 12:17:26 PM

Could not get visible Sonos devices from 192.168.3.250: HTTPConnectionPool(host='192.168.3.250', port=1400): Max retries exceeded with url: /xml/DeviceProperties1.xml (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa13b97f6d0>: Failed to establish a new connection: [Errno 111] Connection refused'))
Could not get visible Sonos devices from 192.168.3.233: HTTPConnectionPool(host='192.168.3.233', port=1400): Max retries exceeded with url: /xml/DeviceProperties1.xml (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fa13b9b2c20>, 'Connection to 192.168.3.233 timed out. (connect timeout=10)'))

Additional information

No response

@home-assistant
Copy link

Hey there @cgtobi, @jjlawren, mind taking a look at this issue as it has been labeled with an integration (sonos) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sonos can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign sonos Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


sonos documentation
sonos source
(message by IssueLinks)

@jjlawren
Copy link
Contributor

I believe this should be fixed by #90648.

@PeteRager
Copy link
Contributor

Should be fixed in 2923.6.0, upgrade when you get the chance, see if it has gone away.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants