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

Home Assistant warning message in log #145

Open
s1affka opened this issue Jun 18, 2024 · 1 comment
Open

Home Assistant warning message in log #145

s1affka opened this issue Jun 18, 2024 · 1 comment

Comments

@s1affka
Copy link

s1affka commented Jun 18, 2024

The problem

homeassistant.util.loop
util/loop.py:84

Detected blocking call to open inside the event loop by custom integration 'auto_backup' at custom_components/auto_backup/handlers.py, line 146: with open(destination, "wb") as file: (offender: /config/custom_components/auto_backup/handlers.py, line 146: with open(destination, "wb") as file:), please create a bug report at https://github.com/jcwillox/hass-auto-backup/issues Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/auto_backup/handlers.py", line 146, in download_backup with open(destination, "wb") as file:

What version of Auto Backup has the issue?

1.5.0

What version of Home Assistant are you running?

Home Assistant Core 2024.6.3

What type of installation are you running?

Home Assistant OS

If you're running HA OS/Supervised, what version of the Supervisor are you running?

Supervisor 2024.06.0

Example YAML snippet

Core 2024.6.3
Supervisor 2024.06.0
Operating System 12.3

Anything in the logs that might be useful for us?

homeassistant.util.loop
util/loop.py:84

Detected blocking call to open inside the event loop by custom integration 'auto_backup' at custom_components/auto_backup/handlers.py, line 146: with open(destination, "wb") as file: (offender: /config/custom_components/auto_backup/handlers.py, line 146: with open(destination, "wb") as file:), please create a bug report at https://github.com/jcwillox/hass-auto-backup/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/auto_backup/handlers.py", line 146, in download_backup with open(destination, "wb") as file:

Additional information

No response

Doorshifter added a commit to Doorshifter/hass-auto-backup that referenced this issue Dec 8, 2024
- Resolved Home Assistant warning about blocking file operations in the `auto_backup` integration (jcwillox#145).
- Updated `handlers.py` to replace synchronous `open` calls with `aiofiles.open` for non-blocking file writes.
- Improved compatibility with Home Assistant's asyncio architecture, preventing event loop warnings.
- Verified changes to ensure integration functionality remains intact.
@Doorshifter
Copy link

I've addressed the blocking file operation warning by replacing synchronous file writes with aiofiles. This should resolve the issue while maintaining the integration's functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants