diff mbox

[Branch,~linaro-validation/lava-scheduler/trunk] Rev 75: * change fake-dispatcher to do the fake test result outputty thing as the very

Message ID 20110824103610.7645.52389.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Aug. 24, 2011, 10:36 a.m. UTC
------------------------------------------------------------
revno: 75
committer: Michael-Doyle Hudson <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Wed 2011-08-24 22:33:21 +1200
message:
   * change fake-dispatcher to do the fake test result outputty thing as the very
     last thing -- this exposes a race between jobOobData completing and the
     process exiting.
   * fix the race by using the same lock the Job instance uses to serialized db
     operations.
modified:
  fake-dispatcher
  lava_scheduler_daemon/board.py


--
lp:lava-scheduler
https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk

You are subscribed to branch lp:lava-scheduler.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-scheduler/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'fake-dispatcher'
--- fake-dispatcher	2011-08-17 03:09:36 +0000
+++ fake-dispatcher	2011-08-24 10:33:21 +0000
@@ -8,8 +8,3 @@ 
 echo
 done
 echo dashboard-put-result: http://disney.com >&3
-for i in `seq 3 6`; do
-sleep 2
-echo $i
-done
-echo ending

=== modified file 'lava_scheduler_daemon/board.py'
--- lava_scheduler_daemon/board.py	2011-08-22 05:39:45 +0000
+++ lava_scheduler_daemon/board.py	2011-08-24 10:33:21 +0000
@@ -23,17 +23,19 @@ 
 
     delimiter = '\n'
 
-    def __init__(self, source, board_name):
+    def __init__(self, source, board_name, _source_lock):
         self.source = source
         self.board_name = board_name
+        self._source_lock = _source_lock
 
     def lineReceived(self, line):
         if ':' not in line:
             self.logger.error('malformed oob data: %r' % line)
             return
         key, value = line.split(':', 1)
-        self.source.jobOobData(
-            self.board_name, key, value.lstrip()).addErrback(
+        self._source_lock.run(
+            self.source.jobOobData, self.board_name, key,
+            value.lstrip()).addErrback(
                 catchall_errback(self.logger))
 
 
@@ -41,11 +43,11 @@ 
 
     logger = logging.getLogger(__name__ + '.DispatcherProcessProtocol')
 
-    def __init__(self, deferred, log_file, source, board_name):
+    def __init__(self, deferred, log_file, source, board_name, _source_lock):
         self.deferred = deferred
         self.log_file = log_file
         self.source = source
-        self.oob_data = OOBDataProtocol(source, board_name)
+        self.oob_data = OOBDataProtocol(source, board_name, _source_lock)
 
     def childDataReceived(self, childFD, data):
         if childFD == 3:
@@ -94,7 +96,7 @@ 
         with os.fdopen(fd, 'wb') as f:
             json.dump(json_data, f)
         self._protocol = DispatcherProcessProtocol(
-            d, log_file, self.source, self.board_name)
+            d, log_file, self.source, self.board_name, self._source_lock)
         self.reactor.spawnProcess(
             self._protocol, self.dispatcher, args=[
                 self.dispatcher, self._json_file, '--oob-fd', '3'],