add PopenModules timeout, courtesy of @luarvique
This commit is contained in:
parent
a2522146b5
commit
4a4e305ab5
|
|
@ -4,7 +4,7 @@ from pycsdr.types import Format
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE, TimeoutExpired
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import pickle
|
import pickle
|
||||||
import logging
|
import logging
|
||||||
|
|
@ -185,8 +185,12 @@ class PopenModule(AutoStartModule, metaclass=ABCMeta):
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.process is not None:
|
if self.process is not None:
|
||||||
self.process.terminate()
|
# Try terminating normally, kill if failed to terminate
|
||||||
self.process.wait()
|
try:
|
||||||
|
self.process.terminate()
|
||||||
|
self.process.wait(3)
|
||||||
|
except TimeoutExpired:
|
||||||
|
self.process.kill()
|
||||||
self.process = None
|
self.process = None
|
||||||
self.reader.stop()
|
self.reader.stop()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue