X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Futils%2Flttngtest%2Fenvironment.py;h=f0e894a69e14c470c7ac56a0f98b8fc3dab3dad4;hb=cebde614e5805e89341ba75d276b4d3e2da7225f;hp=e51f5eb66da533cc36c6dde3ec2d8e235c7636fd;hpb=d46c935357f0c559289245b9e2b25c8cfaf9d831;p=lttng-tools.git diff --git a/tests/utils/lttngtest/environment.py b/tests/utils/lttngtest/environment.py index e51f5eb66..f0e894a69 100644 --- a/tests/utils/lttngtest/environment.py +++ b/tests/utils/lttngtest/environment.py @@ -93,6 +93,7 @@ class _WaitTraceTestApplication: wait_before_exit=False, # type: bool wait_before_exit_file_path=None, # type: Optional[pathlib.Path] ): + self._process = None self._environment = environment # type: Environment self._iteration_count = event_count # File that the application will wait to see before tracing its events. @@ -223,7 +224,7 @@ class _WaitTraceTestApplication: return str(path) def __del__(self): - if not self._has_returned: + if self._process is not None and not self._has_returned: # This is potentially racy if the pid has been recycled. However, # we can't use pidfd_open since it is only available in python >= 3.9. self._process.kill() @@ -315,6 +316,7 @@ class _TraceTestApplication: def __init__(self, binary_path, environment): # type: (pathlib.Path, Environment) + self._process = None self._environment = environment # type: Environment self._has_returned = False @@ -341,7 +343,7 @@ class _TraceTestApplication: self._has_returned = True def __del__(self): - if not self._has_returned: + if self._process is not None and not self._has_returned: # This is potentially racy if the pid has been recycled. However, # we can't use pidfd_open since it is only available in python >= 3.9. self._process.kill()