Open PaulAnnekov opened 7 years ago
Yup, I'm also having this issue. I'm finding that this xiaomi component is now causing CPU spikes on a system that is normally pretty calm. Unfortunately I've had to remove this component for the time being. :(
EDIT: This is my CPU usage (over the last hour). The drop is when I disabled the Xioami component and restarted hass. http://imgur.com/a/w4TkN
I have fixed this in my fork: https://github.com/Danielhiversen/homeassistant You are welcome to test that.
@Danielhiversen great. Switched to your repo, will check. First impression: finally, socket requests are in separate Thread :+1: .
@Danielhiversen Hi, is there any special reason your fork isn't merged into master?
Ask @ravetam. I opened a pull request in February, but @ravetam seems to ignore it.
That's what I thought, don't you want maybe to setup this repository as a separate repository and not a fork, so that people can open issues and pull requests directly to your repository?
Looks like this component is doing its work synchronous in the MainThread. That's unacceptable. Each socket request blocks main HA thread = blocks all the core. If your gateway or anybody between HA and a gateway (e.g. router) will respond too long (I think more than 1 sec), thread will be blocked for this time. E.g. my router likes to make socket timeouts (>10 secs) at least 1 time a day, thread is blocked for 10 seconds, it looks like this:
These calls should be rewritten with asyncore or it should use the same API as other components use (check this and everything below to understand how it should be implemented).