Python3 high CPU Usage

yeah, but I am using Homeassistant OS.

if that is the case:

How did you do that? Where is the command_line in Portainer:

go to “Containers” in the left menu. Then click on the container you want to log into. Then from there in the top section at the bottom there will be 4 choices. The third is “Console”. That’s the one you want.

Or in the “Containers” page you can use the third icon and it takes you to the same place. It’s just not labeled.

thanks!
just to be sure, I only have this (hassio_observer) when clicking containers:

I can click the container leading to:

where Console is available and results in:


that would be it?

I would have thought that you would have more containers than that show up there. On my system the HA Supervised install creates 7 containers (along with all of the containers for each add-on):

Granted I’m on a Debian machine (not HASSOS) but my understanding is that it shouldn’t make any difference as far as Portainer showing all of the containers.

the container you want should be the “homeassistant” container.

He needs to unhide the home assistant containers. The portainer addon hides them by default. See our conversation here:

1 Like

well, on a non-production system I first "removed’ a non vital container, and indeed it immediately popped up listed in the containers. So, I tried to remove the homeassistant and checked, but it has vanished…grr
Maybe We (I) should take this to a separate thread, because this is more of a ‘How to install the test tool’ thread than about actual cpu usage.

I didn’t even know that was a thing.

How does one hide/unhide a container in Portainer?

By adding / removing the container name from Portainer -> Settings -> Hidden containers.

1 Like

I have the same problem with python where can me help, Please!?

The problem is your rest sensor as it uses requests which uses chardet which is very very inefficient with large payloads.

There was a pull request to fix it in 2017, but it went stale:

1 Like

Version 0.117 no longer uses requests for rest sensors and has been switched to async httpx so it won’t be a problem once you upgrade.

Consider trying 0.117b3

1 Like

Thank You Yes it works better :wink:

2020-10-25 00_39_20-Portainer

If you get a chance, would you post a new py-spy in svg format ?

Yes, here please!

click

Thanks. Looks like the switch over to httpx is working as expected :+1:

1 Like

Running 0.117.0b3 Hassio NUC image.

I wish there was some way to work out what is causing this. 100% use of one core:

core
(starts at 2am local to home assistant, im in a different timezone. There is nothing in the log or logbook around this time).

It only shows up on the core cpu sensor. The system monitor shows nothing:

sys-mon

Supervisor cpu is fine:

superv

All other addons are fine. I tried restarting them all anyway, but this caused no change.

Top shows nothing:

And we’ve tried profiler and py-spy without success.

Restarting tames the runaway cpu instantly.

Untitled

Then it happens again a day or three later.

What is the difference between system monitor cpu and core cpu measurements?

It is likely an integration that has a run away thread / loop.

Keeping taking py-spy records each time it happens. Sometimes you have to compare 4 or 5 of them against the idle ones to see the pattern. Make sure to take a py-spy dump as well as it will show the threads.

You may have some luck with strace as well. If you can figure out which thread is running away and attach to it (you can use the py-spy dump output to narrow it down)

Then strace -p <pid> -s 4096 -o trace.log

1 Like

O that’s nice, didn’t realize we could measure per add-on. How do you get all that info per Add-on Tom, is that yet another rest sensor?

also, are those buttons with an embedded mini-graph? If so, could you please share the config of one of them, I would like to try that for sure.

See this topic: HA 0.116 / Supervisor 247 - Core and Supervisor & Addon Stats

In those situations usually helps me cleaning the browser cache.