-
Notifications
You must be signed in to change notification settings - Fork 497
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
[asyncio] Blocking call to import_module in rdata.py #1083
Comments
rdata.py dynamically loads the modules for the various DNS types, so this is the intended behavior. This import happens once per DNS RdataType the first time the type is used. I don't understand what Home Assistant is doing well enough to know why such an import would be a problem. I don't think there is any good workaround for this, alas, though perhaps you could call dns.rdata.get_rdata_class() to preload the classes you are using before entering the event loop. As calling import_module() is legit python for sync and async code, I don't regard this as a bug so it's not something I'm likely to change in the near term, though it's possible that some future release of dnspython could abandon dynamic type loading. |
Home Assistant examines |
Thanks for the explanation! I'll keep thinking about alternatives for the longer term. |
So, I thought more about this and fiddled with some code. I've decided I don't want to solve this specific problem in the distribution as so far it is only really relevant to the Home Assistant case, and there is a workaround for that (code below). Alas this workaround is not useful for the main case where people have problems with dynamic loading, which is "freezing into an executable by static analysis of the source". Here's the preloading code I suggested above:
|
I updated the linked issue with the suggested workaround home-assistant/core#116854 (comment) thanks |
Describe the bug
The rdata.py module of dnspython does blocking I/O while importing other modules. The line causing this issue seams to be here:
dnspython/dns/rdata.py
Line 660 in 9493345
Warning shown in Home Assistant Core:
Is this something which can be fixed in dnspython?
Background information:
I'm the maintainer of the Home Assistant Core integration Minecaft Server, which uses mcstatus as a dependency, which again uses dnspython as a dependency.
Home Assistant Core Issue:
home-assistant/core#116854
Minecraft Server integration call:
https://github.com/home-assistant/core/blob/673bbc13721af0024dd9c4c64ff7f2fe7ac735ff/homeassistant/components/minecraft_server/api.py#L78
mcstatus call:
https://github.com/py-mine/mcstatus/blob/ffefe37cc28da9e98f7028ffc6ebc9d924d2a714/mcstatus/dns.py#L67
Similar issues in Home Assistant Core:
home-assistant/core#116425 (comment)
To Reproduce
Add Minecraft Server integration to Home Assistant Core and check the system logs (I know this isn't very helpful for you).
Context (please complete the following information):
The text was updated successfully, but these errors were encountered: