diff options
Diffstat (limited to 'bitbake/lib/toaster/tests/commands/test_runbuilds.py')
-rw-r--r-- | bitbake/lib/toaster/tests/commands/test_runbuilds.py | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/tests/commands/test_runbuilds.py b/bitbake/lib/toaster/tests/commands/test_runbuilds.py index 3e634835ee..849c227edc 100644 --- a/bitbake/lib/toaster/tests/commands/test_runbuilds.py +++ b/bitbake/lib/toaster/tests/commands/test_runbuilds.py @@ -1,23 +1,11 @@ -#! /usr/bin/env python -# ex:ts=4:sw=4:sts=4:et -# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +#! /usr/bin/env python3 # # BitBake Toaster Implementation # # Copyright (C) 2016 Intel Corporation # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os @@ -31,12 +19,14 @@ import time import subprocess import signal +import logging + class KillRunbuilds(threading.Thread): """ Kill the runbuilds process after an amount of time """ def __init__(self, *args, **kwargs): super(KillRunbuilds, self).__init__(*args, **kwargs) - self.setDaemon(True) + self.daemon = True def run(self): time.sleep(5) @@ -46,9 +36,12 @@ class KillRunbuilds(threading.Thread): pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."), ".runbuilds.pid") - with open(pidfile_path) as pidfile: - pid = pidfile.read() - os.kill(int(pid), signal.SIGTERM) + try: + with open(pidfile_path) as pidfile: + pid = pidfile.read() + os.kill(int(pid), signal.SIGTERM) + except ProcessLookupError: + logging.warning("Runbuilds not running or already killed") class TestCommands(TestCase): |