Re: [Toaster] [PATCH] toaster: log ProcessLookupError in test_runbuilds

Richard Purdie <[email protected]> Fri, 10 Nov 2023 18:01:55 +0000
Newsgroups org.yoctoproject.lists.toaster,org.openembedded.lists.bitbake-devel
Message-ID <85003f99a53c415511aa2c3efa54a32ee1303e13.camel@linuxfoundation.org>
On Fri, 2023-11-10 at 07:30 -0800, Tim Orling wrote:
> This repeatably fails:
> 
> Exception in thread Thread-2:
> Traceback (most recent call last):
>   File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
>     self.run()
>   File ".../poky/bitbake/lib/toaster/tests/commands/test_runbuilds.py", line 39, in run
>     os.kill(int(pid), signal.SIGTERM)
> ProcessLookupError: [Errno 3] No such process
> 
> Rather than have a hard error, add logging and output as a warning.
> 
> Signed-off-by: Tim Orling <[email protected]>
> ---
>  lib/toaster/tests/commands/test_runbuilds.py | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/toaster/tests/commands/test_runbuilds.py b/lib/toaster/tests/commands/test_runbuilds.py
> index c77d6cf4..14b35764 100644
> --- a/lib/toaster/tests/commands/test_runbuilds.py
> +++ b/lib/toaster/tests/commands/test_runbuilds.py
> @@ -19,6 +19,10 @@ import time
>  import subprocess
>  import signal
>  
> +import logging
> +
> +logger = logging.getLogger("toaster")
> +
>  
>  class KillRunbuilds(threading.Thread):
>      """ Kill the runbuilds process after an amount of time """
> @@ -36,8 +40,11 @@ class KillRunbuilds(threading.Thread):
>  
>          with open(pidfile_path) as pidfile:
>              pid = pidfile.read()
> -            os.kill(int(pid), signal.SIGTERM)
> -
> +            try:
> +                os.kill(int(pid), signal.SIGTERM)
> +            except ProcessLookupError as err:
> +                logger.warning("Failed to kill pid. %s" % err)
> +                pass
>  

Is this a case of "just ensure bitbake has really exited"? If so we
perhaps don't need the warning as it is quite likely it has exited?

Cheers,

Richard