Esempio n. 1
0
 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
Esempio n. 2
0
    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
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
    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
Esempio n. 6
0
    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
Esempio n. 7
0
    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
Esempio n. 8
0
    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
Esempio n. 9
0
    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