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

Detected blocking call to open inside the event loop by integration 'radio_browser' #118618

Closed
SeanPM5 opened this issue Jun 2, 2024 · 6 comments · Fixed by #118842
Closed

Detected blocking call to open inside the event loop by integration 'radio_browser' #118618

SeanPM5 opened this issue Jun 2, 2024 · 6 comments · Fixed by #118842

Comments

@SeanPM5
Copy link
Contributor

SeanPM5 commented Jun 2, 2024

The problem

Can reproduce this simply by opening media browser in sidebar and then clicking on Radio Browser. Below warning gets added to logs when it initially populates the list of radio stations.


Detected blocking call to open inside the event loop by integration 'radio_browser' at homeassistant/components/radio_browser/media_source.py, line 148: countries = await radios.countries(order=Order.NAME) (offender: /usr/local/lib/python3.12/site-packages/pycountry/db.py, line 103: with open(self.filename, encoding="utf-8") as f:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+radio_browser%22

What version of Home Assistant Core has the issue?

2024.6.0b4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Radio Browser

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Jun 2, 2024

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

Code owner commands

Code owners of radio_browser 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 radio_browser Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


radio_browser documentation
radio_browser source
(message by IssueLinks)

@bdraco bdraco added this to the 2024.6.0 milestone Jun 2, 2024
@bdraco
Copy link
Member

bdraco commented Jun 2, 2024

It looks like it will lazy load the countries db in the event loop for https://github.com/pycountry/pycountry/blob/494a4b4c3c567650b877acd808b7ed60af0063cd/src/pycountry/__init__.py#L285

@bdraco
Copy link
Member

bdraco commented Jun 2, 2024

Maybe the simplest fix would be to get the len() of each db in the executor as it will cause it to lazy load https://github.com/pycountry/pycountry/blob/494a4b4c3c567650b877acd808b7ed60af0063cd/src/pycountry/db.py#L152 that will be used if the module has not yet been init/setup

@bdraco
Copy link
Member

bdraco commented Jun 2, 2024

Thanks for reporting. This explains an event loop blocking problem I was trying to track down that I could never pin down that was leading to another issue.

@OhioSpyderman
Copy link

Have a similar issue here:

"Detected blocking call to open inside the event loop by integration 'ps4'"

Related?

Bob.

@OhioSpyderman
Copy link

image

@github-actions github-actions bot locked and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants