[FIX] process termination: do not terminate a process, which has not been started.

This commit is contained in:
Benedek Racz 2020-01-24 16:24:03 +01:00
parent 80f63d47ef
commit e62dfabc82
2 changed files with 10 additions and 5 deletions

View File

@ -292,10 +292,11 @@ class SpawnBase:
try:
logger.info('Deleting...')
self.terminate()
self.disconnect_from_child()
if self.safe_exit:
self.wait()
if self.child_process is not None:
self.terminate()
self.disconnect_from_child()
if self.safe_exit:
self.wait()
except:
traceback.print_exc()
logger.warning(traceback.format_exc())
@ -425,6 +426,10 @@ class SpawnBase:
def isalive(self, console=True):
"""True if the child is still alive, false otherwise"""
if self.child_process is None:
# Child process has not been started... Not alive
return False
try:
self.exitstatus = self.child_process.wait(timeout=0)
except psutil.TimeoutExpired:

View File

@ -162,7 +162,7 @@ class ExceptionPexpect(Exception):
def __filter_not_wexpect(self, trace_list_item):
"""This returns True if list item 0 the string 'wexpect.py' in it. """
if trace_list_item[0].find('wexpect.py') == -1:
if trace_list_item[0].find('spawn.py') == -1:
return True
else:
return False