Open jamesonuk opened 2 weeks ago
It is doing some file io here: https://github.com/mattrayner/pod-point-home-assistant-component/blob/4320be5f60abea50776fba7511c2c6d1cae0643e/custom_components/pod_point/__init__.py#L90
Not sure that is the cause here though.
It is doing some file io here: https://github.com/mattrayner/pod-point-home-assistant-component/blob/4320be5f60abea50776fba7511c2c6d1cae0643e/custom_components/pod_point/__init__.py#L90
Is it though? It is using 'pathlib' not 'os' and I thought that parent was essentially string manipulation? (and __FILE__
is not blocking either?)
Indeed I did attempt to replace pathlib
with aiopath
and you can't await
parent
.
The error does explicitly mention that it is call to import_module
in loader.py
that it is complaining about https://github.com/home-assistant/core/blob/9f839dbb77f0172388d7e6870e0f453d5b04d0ec/homeassistant/loader.py#L1050
I haven't looked at how HA is detecting blocking IO but I would have thought that dynamic importlib
imports in custom components would be picked up when initialising the component not when trying to actually import it?
Path() does io. It may do listdirs and other stuff to find paths. PurePath() does not do io.
Just moving the calculation to a constant at module level would solve that.
But it is unclear if we catch those cases yet, so not sure that is what it is loving here.
It is not my component, just looking to put in a PR to get these warnings out of my logs :) ` More for my info but is it doing IO? If I do
from pathlib import Path
x = Path("/some_other_path/test/xxx")
print (x.parent)
I get /some_other_path/test
output as expected and that path definitely doesn't exist.
From docs on PurePath
You want to make sure that your code only manipulates paths without actually accessing the OS. In this case, instantiating one of the pure classes may be useful since those simply don’t have any OS-accessing operations
Standard path may do os level calls. Which may be blocking. But it os not guaranteed it is. Still a bad thing to use in async code.
But like i said, I'm not sure that is what we detect here.
Ps. Dont over complicate things (no need for aiofiles). Move stuff like this to module top level next to imports as a constant.
As I said it is not my integration and looking to do the fewest changes.
Did swap to PurePath
and still get the warning so appears this is not the issue.
Might try and dig into the new blocking check code and see if I can see where this is actually trigger from
This, update from 2024.6.4 to 2024.7.1, caused 3 of my integration to stop working because this issue with the 'import_module'. Besides the above mentioned error. The integration page just says orange exclamation mark with 'not loaded', and no option to reload. Only delete. These integrations are;
After restore of version 2024.6.4 the integrations worked right away. Is not a solution but workaround for the time being.
@Floriszz you need to report that to the developers of those components. This issue is about pod_point.
@elupus , thanks I'll. I get the same error. So they all share the same problem. I will point them to here for a resolution direction.
The problem
Logs report an issue with blocking import when loading custom component (https://github.com/mattrayner/pod-point-home-assistant-component). This integration is not using
importlib
to import dynamically which appears to be the intended check according to the docsWhere
importlib
being used in an integration you get a report likebut see logs below this is reported in core and there is no dynamic import in the integration
What version of Home Assistant Core has the issue?
core-2024.7.0
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
Core
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response