martomi / chiadog

A watch dog providing a peace in mind that your Chia farm is running smoothly 24/7.
MIT License
457 stars 120 forks source link

Defunct zombie git process #194

Closed djdookie closed 3 years ago

djdookie commented 3 years ago

Hi, I just noticed a git zombie process started by chiadog.

This is from my processlist in Ubuntu userx 19328 3325 0 14:47 pts/1 00:00:00 /bin/bash userx 19329 19328 1 14:47 pts/1 00:00:00 python3 main.py --config config.yaml userx 19330 19329 0 14:47 pts/1 00:00:00 [git] \

Having a look into main.py tells me the reason should be this part in version():

command_args = ["git", "describe", "--tags"]
f = subprocess.Popen(command_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return f.stdout.readline().decode(encoding="utf-8").rstrip()

I guess the git subprocess won't die since the stderr is never consumed.

See here: https://www.reddit.com/r/learnpython/comments/3lzv4r/subprocess_becomes_zombie_why/ https://stackoverflow.com/questions/2760652/how-to-kill-or-avoid-zombie-processes-with-subprocess-module/2761237#2761237 "Not using Popen.communicate() or call() will result in a zombie process."

It's not a big deal since this only happens once at start, but I'd prefer to not have any permanent zombie processes. Finally, this should be a very easy and quick fix!

pieterhelsen commented 3 years ago

Thanks for the feedback. I'll pick up this one!

pieterhelsen commented 3 years ago

I have a branch ready that implements communicate(), however I wasn't able to reproduce the errors on my systems. Could you have a look and see if this fixes the issue on your end @djdookie ? (see above for PR)

djdookie commented 3 years ago

Works like a charm. No zombie processes anymore on your branch #195. Thanks for implementing this fix so quickly!