diff mbox series

[2/8] Toaster: Update orm.models to catch error ProcessLookupError

Message ID 20231030195037.232912-2-alassane.yattara@savoirfairelinux.com
State New
Headers show
Series [1/8] Toaster: Update toaster-requirements.txt to add pytest and some plugin's | expand

Commit Message

Alassane Yattara Oct. 30, 2023, 7:50 p.m. UTC
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
 lib/toaster/orm/models.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Tim Orling Oct. 31, 2023, 2:27 p.m. UTC | #1
On Mon, Oct 30, 2023 at 12:51 PM Alassane Yattara <
alassane.yattara@savoirfairelinux.com> wrote:

> Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
> ---
>  lib/toaster/orm/models.py | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
> index 0d503a51..4f6d2147 100644
> --- a/lib/toaster/orm/models.py
> +++ b/lib/toaster/orm/models.py
> @@ -1389,9 +1389,6 @@ class Machine(models.Model):
>          return "Machine " + self.name + "(" + self.description + ")"
>
>
> -
> -
> -
>  class BitbakeVersion(models.Model):
>
>      name = models.CharField(max_length=32, unique = True)
> @@ -1838,6 +1835,7 @@ class LogMessage(models.Model):
>      def __str__(self):
>          return force_bytes('%s %s %s' % (self.get_level_display(),
> self.message, self.build))
>
> +
>

Why the extra new lines? Is this a PEP-8 thing?


>  def invalidate_cache(**kwargs):
>      from django.core.cache import cache
>      try:
> @@ -1845,6 +1843,7 @@ def invalidate_cache(**kwargs):
>      except Exception as e:
>        logger.warning("Problem with cache backend: Failed to clear cache:
> %s" % e)
>
> +
>  def signal_runbuilds():
>      """Send SIGUSR1 to runbuilds process"""
>      try:
> @@ -1853,6 +1852,9 @@ def signal_runbuilds():
>              os.kill(int(pidf.read()), SIGUSR1)
>      except FileNotFoundError:
>          logger.info("Stopping existing runbuilds: no current process
> found")
> +    except ProcessLookupError:
>

We should at a minimum be doing a logger.warning here.

ProcessLookupError here most likely means that a subprocess has failed or
been killed and we should not just be ignoring that.


> +        pass
> +
>
>  class Distro(models.Model):
>      search_allowed_fields = ["name", "description",
> "layer_version__layer__name"]
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#15325):
> https://lists.openembedded.org/g/bitbake-devel/message/15325
> Mute This Topic: https://lists.openembedded.org/mt/102283456/924729
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [
> ticotimo@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/lib/toaster/orm/models.py b/lib/toaster/orm/models.py
index 0d503a51..4f6d2147 100644
--- a/lib/toaster/orm/models.py
+++ b/lib/toaster/orm/models.py
@@ -1389,9 +1389,6 @@  class Machine(models.Model):
         return "Machine " + self.name + "(" + self.description + ")"
 
 
-
-
-
 class BitbakeVersion(models.Model):
 
     name = models.CharField(max_length=32, unique = True)
@@ -1838,6 +1835,7 @@  class LogMessage(models.Model):
     def __str__(self):
         return force_bytes('%s %s %s' % (self.get_level_display(), self.message, self.build))
 
+
 def invalidate_cache(**kwargs):
     from django.core.cache import cache
     try:
@@ -1845,6 +1843,7 @@  def invalidate_cache(**kwargs):
     except Exception as e:
       logger.warning("Problem with cache backend: Failed to clear cache: %s" % e)
 
+
 def signal_runbuilds():
     """Send SIGUSR1 to runbuilds process"""
     try:
@@ -1853,6 +1852,9 @@  def signal_runbuilds():
             os.kill(int(pidf.read()), SIGUSR1)
     except FileNotFoundError:
         logger.info("Stopping existing runbuilds: no current process found")
+    except ProcessLookupError:
+        pass
+
 
 class Distro(models.Model):
     search_allowed_fields = ["name", "description", "layer_version__layer__name"]