introduce protected client writes, to avoid hanging connections

This commit is contained in:
Jakob Ketterl
2019-05-10 20:08:22 +02:00
parent 1108cd9a96
commit 52098cf9f9
2 changed files with 30 additions and 22 deletions

View File

@ -278,12 +278,7 @@ class SpectrumThread(object):
time.sleep(1)
else:
for c in self.clients:
try:
c.write_spectrum_data(data)
except OSError:
self.remove_client(c)
except ValueError:
pass
c.write_spectrum_data(data)
dsp.stop()
print("spectrum thread shut down")
@ -508,6 +503,7 @@ class CpuUsageThread(threading.Thread):
self.shutdown()
def shutdown(self):
print("shutting down cpu usage thread")
CpuUsageThread.sharedInstance = None
self.doRun = False
if self.doRun:
if CpuUsageThread.sharedInstance == self:
CpuUsageThread.sharedInstance = None
self.doRun = False