Zombie processes spawned from python

i’ve noticed some instability this past week. so i did some digging into my logs and checking processes.

for some reason python is spawning a bunch of child processes then not checking them and closing them out. when i logged into today and ran top, i had over 2208 zombie processes. when checking the parent was the main python process. the zombie process seems to be a sh program running it

anyone know why this is?

from an HA config perspective, i have two command line sensors to check the status of my MQTT and Portainer containers. maybe its that that is creating these when checking and not properly exiting the program?

even after killing the parent and zombies, in the past 30 minutes since then, i already have another 38 zombie processes running. i figure i’ll comment out these command line sensors and see if they are part of the problem or not.

if anyone has seen similar issues, i’d love to hear

well, i just commented out my command line sensors, and viola, no more zombie processes spawning. looks like there is an issue with that sensor template. however, digging into that is beyong my knowledge. i’ll keep an eye on this the next few days to check and see if any more zombies pop back up.

for reference, this was what the sensor template was, in case someone may be able to point out something i did wrong in my command line code

# MQTT docker container sensor
  - platform: command_line
    command: '(echo >/dev/tcp/x.x.x.x/1883) &>/dev/null && echo Online || echo Offline'
    name: 'MQTT Status'
    payload_on: 'Online'
    payload_off: 'Offline'

# Portainer docker container sensor
  - platform: command_line
    command: '(echo >/dev/tcp/x.x.x.x/9000) &>/dev/null && echo Online || echo Offline'
    name: 'Portainer Status'
    payload_on: 'Online'
    payload_off: 'Offline'

i’ve tried running the commands directly from the command line and it exits just fine.

i added the MQTT command line sensor, restarted HA, and within seconds i got a zombie process.
i don’t get any errors in HA logs