bbangert / buildbot-xmlrpc


Buildbot fork with additional XMLRPC methods and bugfixes.
Clone URL : http://bitbucket.org/bbangert/buildbot-xmlrpc/ (size: 1.9 MB)
commit 699: 411fcacdc1b8
parent 698: d948c043c9b0
branch: default
send header showing elapsed time after slave/commands.py ShellCommand completes
zooko@zooko.com
9 months ago

Changed (Δ529 bytes):

raw changeset »

buildbot/slave/commands.py (12 lines added, 1 lines removed)

Up to file-list buildbot/slave/commands.py:

@@ -224,6 +224,14 @@ class ShellCommand:
224
224
    KILL = "KILL"
225
225
    CHUNK_LIMIT = 128*1024
226
226
227
    # For sending elapsed time:
228
    startTime = None
229
    elapsedTime = None
230
    # I wish we had easy access to CLOCK_MONOTONIC in Python:
231
    # http://www.opengroup.org/onlinepubs/000095399/functions/clock_getres.html
232
    # Then changes to the system clock during a run wouldn't effect the "elapsed
233
    # time" results.
234
227
235
    def __init__(self, builder, command,
228
236
                 workdir, environ=None,
229
237
                 sendStdout=True, sendStderr=True, sendRC=True,
@@ -409,6 +417,7 @@ class ShellCommand:
409
417
        # called right after we return, but somehow before connectionMade
410
418
        # were called, then kill() would blow up).
411
419
        self.process = None
420
        self.startTime = time.time()
412
421
        p = reactor.spawnProcess(self.pp, argv[0], argv,
413
422
                                 self.environ,
414
423
                                 self.workdir,
@@ -462,7 +471,8 @@ class ShellCommand:
462
471
            self.timer.reset(self.timeout)
463
472
464
473
    def finished(self, sig, rc):
465
        log.msg("command finished with signal %s, exit code %s" % (sig,rc))
474
        self.elapsedTime = time.time() - self.startTime
475
        log.msg("command finished with signal %s, exit code %s, elapsedTime: %0.6f" % (sig,rc,self.elapsedTime))
466
476
        for w in self.logFileWatchers:
467
477
             # this will send the final updates
468
478
            w.stop()
@@ -473,6 +483,7 @@ class ShellCommand:
473
483
                self.sendStatus(
474
484
                    {'header': "process killed by signal %d\n" % sig})
475
485
            self.sendStatus({'rc': rc})
486
        self.sendStatus({'header': "elapsedTime=%0.6f\n" % self.elapsedTime})
476
487
        if self.timer:
477
488
            self.timer.cancel()
478
489
            self.timer = None