コード例 #1
0
ファイル: middleware.py プロジェクト: cyberdelia/forestry
 def process_view(self, request, view_func, view_args, view_kwargs):
     start_time = instant()
     response = view_func(request, *view_args, **view_kwargs)
     duration = instant() - start_time
     logger.info(
         "",
         extra={
             "path": request.path,
             "rendering_time": duration,
             "status_code": response.status_code,
             "request": request,
         },
     )
     return response
コード例 #2
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def duration_so_far(self):
        """Return how the duration so far.

        :returns: the duration from the time the Interval was started if the
            interval is running, otherwise ``False``.
        """
        if self._start_instant is None:
            return False
        if self._stop_instant is None:
            return (instant() - self._start_instant)
        return False
コード例 #3
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def duration(self):
        """Returns the Float value of the interval, the value is in seconds.

        If the interval has not had stop called yet,
        it will report the number of seconds in the interval up to the current point in time.
        """
        if self._stop_instant is None:
            return (instant() - self._start_instant)
        if self._duration is None:
            self._duration = (self._stop_instant - self._start_instant)
        return self._duration
コード例 #4
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def duration_so_far(self):
        """Return how the duration so far.

        :returns: the duration from the time the Interval was started if the
            interval is running, otherwise ``False``.
        """
        if self._start_instant is None:
            return False
        if self._stop_instant is None:
            return (instant() - self._start_instant)
        return False
コード例 #5
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def duration(self):
        """Returns the Float value of the interval, the value is in seconds.

        If the interval has not had stop called yet,
        it will report the number of seconds in the interval up to the current point in time.
        """
        if self._stop_instant is None:
            return (instant() - self._start_instant)
        if self._duration is None:
            self._duration = (self._stop_instant - self._start_instant)
        return self._duration
コード例 #6
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def start(self):
        """Mark the start of the interval.

        Calling start on an already started interval has no effect.
        An interval can only be started once.

        :returns: ``True`` if the interval is truely started True otherwise ``False``.
        """
        if self._start_instant is None:
            self._start_instant = instant()
            return True
        return False
コード例 #7
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def start(self):
        """Mark the start of the interval.

        Calling start on an already started interval has no effect.
        An interval can only be started once.

        :returns: ``True`` if the interval is truely started True otherwise ``False``.
        """
        if self._start_instant is None:
            self._start_instant = instant()
            return True
        return False
コード例 #8
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def stop(self):
        """Mark the stop of the interval.

        Calling stop on an already stopped interval has no effect.
        An interval can only be stopped once.

        :returns: the duration if the interval is truely stopped otherwise ``False``.
        """
        if self._start_instant is None:
            raise IntervalException("Attempt to stop an interval that has not started.")
        if self._stop_instant is None:
            self._stop_instant = instant()
            self._duration = (self._stop_instant - self._start_instant)
            return self._duration
        return False
コード例 #9
0
ファイル: interval.py プロジェクト: c0ns0le/zenoss-4
    def stop(self):
        """Mark the stop of the interval.

        Calling stop on an already stopped interval has no effect.
        An interval can only be stopped once.

        :returns: the duration if the interval is truely stopped otherwise ``False``.
        """
        if self._start_instant is None:
            raise IntervalException(
                "Attempt to stop an interval that has not started.")
        if self._stop_instant is None:
            self._stop_instant = instant()
            self._duration = (self._stop_instant - self._start_instant)
            return self._duration
        return False