~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/timeline/timedaction.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-09-06 23:25:14 UTC
  • mfrom: (11510.3.1 oops)
  • Revision ID: launchpad@pqm.canonical.com-20100906232514-orqk5zg4gphjlzll
[release-critical=thumper][r=thumer][ui=none][bug=632022] In TimedAction.logTuple use the time since start for the duration of incomplete actions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        """Return a 4-tuple suitable for errorlog's use."""
48
48
        offset = self._td_to_ms(self.start - self.timeline.baseline)
49
49
        if self.duration is None:
50
 
            # This action wasn't finished: give it a duration that will stand
51
 
            # out. This is pretty normal when action ends are recorded by
52
 
            # callbacks rather than stack-like structures. E.g. storm 
53
 
            # tracers in launchpad:
 
50
            # This action wasn't finished: pretend it has finished now
 
51
            # (even though it hasn't). This is pretty normal when action ends
 
52
            # are recorded by callbacks rather than stack-like structures. E.g.
 
53
            # storm tracers in launchpad:
54
54
            # log-trace START : starts action
55
55
            # timeout-trace START : raises 
56
56
            # log-trace FINISH is never called.
57
 
            length = 999999
 
57
            length = self._td_to_ms(self._interval_to_now())
58
58
        else:
59
59
            length = self._td_to_ms(self.duration)
60
60
        return (offset, offset + length, self.category, self.detail)
66
66
 
67
67
    def finish(self):
68
68
        """Mark the TimedAction as finished."""
69
 
        self.duration = datetime.datetime.now(UTC) - self.start
 
69
        self.duration = self._interval_to_now()
 
70
 
 
71
    def _interval_to_now(self):
 
72
        return datetime.datetime.now(UTC) - self.start