isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

daemon with restart crash because of _check_sane_and_get_gpg_version #270

Open liz367 opened 4 years ago

liz367 commented 4 years ago

i am using python 3.7.0, gnupg 2.3.1 in centos 7. i want to build a daemon for my service and add a function that monitors the sigchild signal, and restart my service whenever it crashes

i think the daemon code should be right. when i add the monitor&restart function, it can work correctly with a simple service:

while True:
    print(1)
    time.sleep(5)

but something wrong when i use gnupg in my service code, even like this simple demo:

time.sleep(3)
print('start')
import gnupg
gnupg.GPG(homedir='/root/.gnupg')
while True:
    print(1)
    time.sleep(5)

the daemon catch so many sigchild signal, and the log show that maybe something go wrong in .../gunpg/_meta/_check_sane_and_get_gpg_version(func)/_read_data(func)/log.debug("Reading data from stream %r..." % stream.repr())

i try to seek for the reason, but i can't handle this question. but i find if i cancel the function _check_sane_and_get_gpg_version call, the restart function will work. so i think maybe my daemon code make the proc = self.open_subprocess(["--list-config", "--with-colons"])going wrong.

can anyone help me to figure out the cause? thanks! this is my daemon code daemon.zip