drain subprocess pipes to free up file descriptors, refs #146

This commit is contained in:
Jakob Ketterl 2020-08-05 20:01:57 +02:00
parent 7234ff4309
commit a77108dd0c

View File

@ -504,12 +504,18 @@ class dsp(object):
if self.secondary_process_fft: if self.secondary_process_fft:
try: try:
os.killpg(os.getpgid(self.secondary_process_fft.pid), signal.SIGTERM) os.killpg(os.getpgid(self.secondary_process_fft.pid), signal.SIGTERM)
# drain any leftover data to free file descriptors
self.secondary_process_fft.communicate()
self.secondary_process_fft = None
except ProcessLookupError: except ProcessLookupError:
# been killed by something else, ignore # been killed by something else, ignore
pass pass
if self.secondary_process_demod: if self.secondary_process_demod:
try: try:
os.killpg(os.getpgid(self.secondary_process_demod.pid), signal.SIGTERM) os.killpg(os.getpgid(self.secondary_process_demod.pid), signal.SIGTERM)
# drain any leftover data to free file descriptors
self.secondary_process_demod.communicate()
self.secondary_process_demod = None
except ProcessLookupError: except ProcessLookupError:
# been killed by something else, ignore # been killed by something else, ignore
pass pass
@ -848,6 +854,8 @@ class dsp(object):
if self.process is not None: if self.process is not None:
try: try:
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM) os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
# drain any leftover data to free file descriptors
self.process.communicate()
self.process = None self.process = None
except ProcessLookupError: except ProcessLookupError:
# been killed by something else, ignore # been killed by something else, ignore