[6/8] toaster: orm models Handle run builds process not yet running

Submitted by Michael Wood on Oct. 21, 2016, 5:07 p.m. | Patch ID: 133148

Details

Message ID 1477069666-25701-7-git-send-email-michael.g.wood@intel.com
State New
Headers show

Commit Message

Michael Wood Oct. 21, 2016, 5:07 p.m.
During tests we may want to call the runbuilds process manually for
example when doing a "one shot" approach rather than a long running
process during tests.

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
---
 bitbake/lib/toaster/orm/models.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index a7de57c..6b00916 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1741,8 +1741,12 @@  def invalidate_cache(**kwargs):
 
 def signal_runbuilds():
     """Send SIGUSR1 to runbuilds process"""
-    with open(os.path.join(os.getenv('BUILDDIR'), '.runbuilds.pid')) as pidf:
-        os.kill(int(pidf.read()), SIGUSR1)
+    try:
+        with open(os.path.join(os.getenv('BUILDDIR'),
+                               '.runbuilds.pid')) as pidf:
+            os.kill(int(pidf.read()), SIGUSR1)
+    except FileNotFoundError:
+        logger.info("Run builds doesn't appear to be running yet")
 
 django.db.models.signals.post_save.connect(invalidate_cache)
 django.db.models.signals.post_delete.connect(invalidate_cache)