def stop(self):
StopCheck = True
NumProcs = len(self._thread_list)
ProcsStopped = 0
while StopCheck:
for _idx, _t in enumerate(self._thread_list):
_qmsg = _t.finq
if _qmsg == 'completed_run':
_t.stop()
ProcsStopped += 1
logging.info("Stopped thread %s with pid %s with kwargs \
%s" % (_idx+1, _t.getPID(), _t))
if _qmsg == 'error':
_t.stop()
logging.info("Error on thread %s with pid %s with kwargs \
%s" % (_idx+1, _t.getPID(), _t))
StopCheck = False
if NumProcs == ProcsStopped:
StopCheck = False
sleep(0.5)
print "\n\nGoodbye..."
for pid in self._pid_list:
p = psutil.Process(pid)
p.terminate()
exit(0)
评论列表
文章目录