def stop(self):
"""Join the thread. Kill the running subprocess and interrupt the sleeping.
:return:
"""
self.is_running = False
if self.thread is not None:
# kill subprocess
if self.process is not None:
print("kill process")
try:
os.killpg(os.getpgid(self.process.pid), signal.SIGTERM)
except ProcessLookupError as e:
print(e)
# interrupt sleeping
self.stop_event.set()
self.stop_event = None
self.thread.join()
self.thread = None
评论列表
文章目录