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

Warning: Detected blocking call to open inside the event loop by custom integration 'tapo_control' #612

Closed
catalinbordan opened this issue Jun 18, 2024 · 5 comments
Labels
Fixed Bug has been fixed.
Milestone

Comments

@catalinbordan
Copy link

Description

I think it is coming from new version of Home Assistant 2024.6.3
Almost 19k hits from the last 12h.
I also have this warning: Recording is currently in progress.
I did not see any issues in regarding the use of integration.

Reproduction Steps

I had activated media sync for all my 3 cameras in /media/tapo

Expected behavior

no warning about

If applicable, add error logs.

Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 17 June 2024 at 19:35:02 (18096 occurrences)
Last logged: 10:40:11

Detected blocking call to open inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 513: downloadedFile = await downloader.downloadFile( (offender: /usr/local/lib/python3.12/site-packages/pytapo/media_stream/convert.py, line 25: file = open(tempVideoFileLocation, "wb")), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/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/tapo_control/init.py", line 752, in mediaSync await getRecording( File "/config/custom_components/tapo_control/utils.py", line 513, in getRecording downloadedFile = await downloader.downloadFile(
Detected blocking call to open inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 513: downloadedFile = await downloader.downloadFile( (offender: /usr/local/lib/python3.12/site-packages/pytapo/media_stream/convert.py, line 29: file = open(tempAudioFileLocation, "wb")), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/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/tapo_control/init.py", line 752, in mediaSync await getRecording( File "/config/custom_components/tapo_control/utils.py", line 513, in getRecording downloadedFile = await downloader.downloadFile(
Detected blocking call to open inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 513: downloadedFile = await downloader.downloadFile( (offender: /usr/local/lib/python3.12/site-packages/pytapo/media_stream/downloader.py, line 45: with open(fileName, "rb") as f:), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/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/tapo_control/init.py", line 752, in mediaSync await getRecording( File "/config/custom_components/tapo_control/utils.py", line 513, in getRecording downloadedFile = await downloader.downloadFile(
Detected blocking call to open inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 265: with open(filePathThumb, "wb") as binary_file: (offender: /config/custom_components/tapo_control/utils.py, line 265: with open(filePathThumb, "wb") as binary_file:), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/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/tapo_control/init.py", line 752, in mediaSync await getRecording( File "/config/custom_components/tapo_control/utils.py", line 540, in getRecording await processDownload( File "/config/custom_components/tapo_control/utils.py", line 233, in processDownload await generateThumb( File "/config/custom_components/tapo_control/utils.py", line 265, in generateThumb with open(filePathThumb, "wb") as binary_file:

Device Firmware

last fw without issues related to cloud pswd

Integration Version

5.4.18

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Home assistant on VM

Search for similar issues

Yes

Additional information

No response

@JurajNyiri
Copy link
Owner

Fixed in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.4.19.

@catalinbordan
Copy link
Author

catalinbordan commented Jul 4, 2024

thank you very much!
I installed right now and I still have some issues.
please see bellow:

Logger: homeassistant.util.loop
Source: util/loop.py:136
First occurred: 16:32:16 (2 occurrences)
Last logged: 16:32:16

Detected blocking call to open with args ('/media/tapo/door/thumbs/1720087612-1720087690.jpg', 'rb') inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 480: shutil.copyfile(coldFilePath, hotFilePath) (offender: /usr/local/lib/python3.12/shutil.py, line 260: with open(src, 'rb') as fsrc:), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open 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 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, 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 "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 187, in websocket_browse_media media = await async_browse_media(hass, msg.get("media_content_id", "")) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 135, in async_browse_media item = await _get_media_item(hass, media_content_id, None).async_browse() File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 80, in async_browse return await self.async_media_source().async_browse_media(self) File "/config/custom_components/tapo_control/media_source.py", line 214, in async_browse_media thumbLink = getWebFile( File "/config/custom_components/tapo_control/utils.py", line 487, in getWebFile hotFilePath = getHotFile(hass, entry_id, startDate, endDate, folder) File "/config/custom_components/tapo_control/utils.py", line 480, in getHotFile shutil.copyfile(coldFilePath, hotFilePath)
Detected blocking call to open with args ('/config/www/tapo_control/523721c162e428d5ccfbfb8d32989b3b/thumbs/cdc256ee01e6377337adcf53fd129fc422f00b17ccac45a990a9c322bfbe6414.jpg', 'wb') inside the event loop by custom integration 'tapo_control' at custom_components/tapo_control/utils.py, line 480: shutil.copyfile(coldFilePath, hotFilePath) (offender: /usr/local/lib/python3.12/shutil.py, line 262: with open(dst, 'wb') as fdst:), please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open 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 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, 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 "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 187, in websocket_browse_media media = await async_browse_media(hass, msg.get("media_content_id", "")) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 135, in async_browse_media item = await _get_media_item(hass, media_content_id, None).async_browse() File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 80, in async_browse return await self.async_media_source().async_browse_media(self) File "/config/custom_components/tapo_control/media_source.py", line 214, in async_browse_media thumbLink = getWebFile( File "/config/custom_components/tapo_control/utils.py", line 487, in getWebFile hotFilePath = getHotFile(hass, entry_id, startDate, endDate, folder) File "/config/custom_components/tapo_control/utils.py", line 480, in getHotFile shutil.copyfile(coldFilePath, hotFilePath)

I see, it stills want to put data in the default place defined by integrations. Please see second line of the logger. I have configured to save in media folder because I do not want to back up this files(the are bigger)

@JurajNyiri JurajNyiri reopened this Jul 4, 2024
@JurajNyiri
Copy link
Owner

@JurajNyiri
Copy link
Owner

JurajNyiri commented Jul 4, 2024

@catalinbordan when you try to play a recording via HA, it needs to copy it into the HA www folder temporarily. It will auto delete it after an hour.

@catalinbordan
Copy link
Author

thanks for explanations and for the updated code. I have installed, restarted and again watched some videos. seems ok, no errors.
I will check later if I will find some files lost/not deleted.
You are the best :)

@JurajNyiri JurajNyiri added the Fixed Bug has been fixed. label Jul 4, 2024
marcosngomezi pushed a commit to marcosngomezi/HomeAssistant-Tapo-Control that referenced this issue Jul 20, 2024
JurajNyiri added a commit that referenced this issue Jul 20, 2024
* changes

* tapo-siren-fix

* getMost-list-breaking-change

* siren-and-select

* comments

* fixes-and-comments

* numbers

* siren

* unneded-mapings

* cleanup

* testing-fixes

* cleanup

* Fix: PR does not work with C200 1.0 1.3.6

* fix-siren

* Update README.md to add instructions in case the cloud password does not work.

* Update README.md

* Update README.md

* Update README.md

* Implement color mode

Reference:
https://developers.home-assistant.io/docs/core/entity/light#color-modes

> New integrations must implement both color_mode and supported_color_modes.
> If an integration is upgraded to support color mode, both color_mode and
> supported_color_modes should be implemented.

This also fixes this warning at startup:

```
WARNING (MainThread) [homeassistant.components.light] None (<class 'custom_components.tapo_control.light.TapoWhitelight'>) does not set supported color modes, this will stop working in Home Assistant Core 2025.3, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues
```

* Create ru.json

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Fix #568: IP address is not a supported Tapo device

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

* Update issues.yml

Temporarily disable cloud password close bot

* Update issues.yml

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* changes

* tapo-siren-fix

* getMost-list-breaking-change

* siren-and-select

* comments

* fixes-and-comments

* numbers

* siren

* unneded-mapings

* cleanup

* testing-fixes

* cleanup

* fix-siren

* Handle cleanup of config entry

* Fix: PR does not work with C200 1.0 1.3.6

* alarm-status-false-default

* Fix #616: Warning for async_forward_entry_setup

* Fix #612, #615, #530, #525

* Fix: Blocking call when copying file from cold to hot storage

* Add: Binary sensor with details about media sync setup

* Fix #572: ffmpeg for sound detection doesn't terminate on Home Assistant restart

* Fix #561: Unexpected error fetching Tapo resource status data

* Fix #571: Incorrect device_class for D230 doorbell battery sensor

* Fix: Descalate "Recording is currently in progress." warning to info on media sync

* Add: HDR switch

* Add: Experimental optimization for battery cameras

* Fix: Update interval is now based on whether the device has a battery or not

* Update: Automatically determine whether the device is currently running on battery or not and adjust update interval

* Fix: Camera entities ignoring update threshold

* Update README.md

* Update README.md

* Create add_camera_with_new_firmware.md

* Update README.md

* Update add_camera_with_new_firmware.md

* Update add_camera_with_new_firmware.md

* Fix #629, #621: Setup for switch entities fails for some cameras

* Add #457: Battery optimization for solar cameras

* Update: Migrate update interval to config entry storage

* Add: Configurable update interval

* Update: Bump version

* Update: Guides for new firmwares workaround

* Update: Readme instructions about stopping use of tapo app not required

* Update: Readme formatting

* Update README.md

* Update add_camera_with_new_firmware.md

* Update README.md

* Fix: Removal of disabled device results in error and warning, time sync debug log

* Fix #450: Config entry name resets on reconfiguration

* Update: Bump version

* Fix: stopManualAlarm instead of start on siren off

* Fix: Mute error on siren on/off

* Update: Revert result_has_error changes

* Update: Ensure compatibility with #632

---------

Co-authored-by: marcosngomezi <[email protected]>
Co-authored-by: Antoine Buchser <[email protected]>
Co-authored-by: L. López <[email protected]>
Co-authored-by: Virenbar <[email protected]>
Co-authored-by: Nathan Spencer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Bug has been fixed.
Projects
None yet
Development

No branches or pull requests

2 participants