improve handling of source processes
This commit is contained in:
parent
6129b92277
commit
0403ebff5c
@ -111,5 +111,6 @@ Support and info: https://groups.io/g/openwebrx
|
|||||||
|
|
||||||
WebSocketConnection.closeAll()
|
WebSocketConnection.closeAll()
|
||||||
Services.stop()
|
Services.stop()
|
||||||
|
SdrService.stopAllSources()
|
||||||
ReportingEngine.stopAll()
|
ReportingEngine.stopAll()
|
||||||
DecoderQueue.stopAll()
|
DecoderQueue.stopAll()
|
||||||
|
@ -259,3 +259,8 @@ class SdrService(object):
|
|||||||
if SdrService.availableProfiles is None:
|
if SdrService.availableProfiles is None:
|
||||||
SdrService.availableProfiles = AvailableProfiles(SdrService.getActiveSources())
|
SdrService.availableProfiles = AvailableProfiles(SdrService.getActiveSources())
|
||||||
return SdrService.availableProfiles
|
return SdrService.availableProfiles
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def stopAllSources():
|
||||||
|
for source in SdrService.getAllSources().values():
|
||||||
|
source.stop()
|
||||||
|
@ -322,6 +322,7 @@ class SdrSource(ABC):
|
|||||||
if self.monitor is None:
|
if self.monitor is None:
|
||||||
break
|
break
|
||||||
testsock = socket.socket()
|
testsock = socket.socket()
|
||||||
|
testsock.settimeout(1)
|
||||||
try:
|
try:
|
||||||
testsock.connect(("127.0.0.1", self.getPort()))
|
testsock.connect(("127.0.0.1", self.getPort()))
|
||||||
testsock.close()
|
testsock.close()
|
||||||
@ -365,6 +366,13 @@ class SdrSource(ABC):
|
|||||||
self.setState(SdrSourceState.STOPPING)
|
self.setState(SdrSourceState.STOPPING)
|
||||||
try:
|
try:
|
||||||
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
|
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
|
||||||
|
if self.monitor:
|
||||||
|
# wait 10 seconds for a regular shutdown
|
||||||
|
self.monitor.join(10)
|
||||||
|
# if the monitor is still running, the process still hasn't ended, so kill it
|
||||||
|
if self.monitor:
|
||||||
|
logger.warning("source has not shut down normally within 10 seconds, sending SIGKILL")
|
||||||
|
os.killpg(os.getpgid(self.process.pid), signal.SIGKILL)
|
||||||
except ProcessLookupError:
|
except ProcessLookupError:
|
||||||
# been killed by something else, ignore
|
# been killed by something else, ignore
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user