Observed issue
==============
When running CI tests against sles12sp5 (with python 3.4) the clean-up
of a stalled test produced the following output:
```
Traceback (most recent call last):
File "./tools/live/test_early_inactive_app.py", line 111, in <module>
log=tap.diagnostic, with_relayd=True, with_sessiond=True
File "/usr/lib64/python3.4/contextlib.py", line 59, in __enter__
return next(self.gen)
File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1192, in test_environment
with_sessiond, log, with_relayd, extra_env_vars, skip_temporary_lttng_home
File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 677, in __init__
self._launch_lttng_relayd() if with_relayd else None
File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 933, in _launch_lttng_relayd
time.sleep(0.1)
File "/home/jenkins/workspace/dev_review_lttng-tools_master_slesbuild/babeltrace_version/stable-2.0/build/std/conf/agents/liburcu_version/master/platform/sles12sp5-amd64/src/lttng-tools/tests/utils/lttngtest/environment.py", line 1044, in _handle_termination_signal
signal_name=signal.strsignal(signal_number)
AttributeError: 'module' object has no attribute 'strsignal'
```
Cause
=====
`signal.strsignal` is introduced in Python 3.8[1].
Solution
========
Check the system version and fall back to using `str(signal_number)`
which will give the numeric signal (e.g. signal.SIGKILL -> 9).
Known drawbacks
===============
None.
References
==========
[1]: https://docs.python.org/3/library/signal.html#signal.strsignal
Change-Id: I04d0560225f8332364d2da2ecd77be2802569cc9
Signed-off-by: Kienan Stewart <kstewart@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
def _handle_termination_signal(self, signal_number, frame):
# type: (int, Optional[FrameType]) -> None
- self._log(
- "Killed by {signal_name} signal, cleaning-up".format(
- signal_name=signal.strsignal(signal_number)
+ if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
+ # signal.strsignal is introduced in python 3.8
+ self._log(
+ "Killed by {signal_name} signal, cleaning-up".format(
+ signal_name=signal.strsignal(signal_number)
+ )
)
- )
+ else:
+ self._log("Killed by signal {}, cleaning-up".format(str(signal_number)))
self._cleanup()
def launch_live_viewer(self, session, hostname=None):