예제 #1
0
        def wrapper(*args, **kwargs):
            startTime = time()
            try:
                return f(*args, **kwargs)
            finally:
                spentTime = time() - startTime
                if spentTime > timeLimit:
                    LOG_TIME_WARNING(spentTime, context if context is not None else f.__name__, tickLength)
                    if not IS_CLIENT and not IS_BOT:
                        incrTickOverspends()

            return
 def exposedtoclientWrapper(*args, **kwArgs):
     try:
         lastTick = time.time()
         result = func(*args, **kwArgs)
         timeSinceLastTick = time.time() - lastTick
         if timeSinceLastTick > time_tracking.DEFAULT_TIME_LIMIT:
             LOG_TIME_WARNING(timeSinceLastTick, context=(getattr(args[0], 'id', 0),
              func.__name__,
              args,
              kwArgs))
             if not IS_CLIENT and not IS_BOT:
                 incrTickOverspends()
         return result
     except:
         _logErrorMessageFromArgs('Exception in exposedtoclient', args)
         LOG_WRAPPED_CURRENT_EXCEPTION(exposedtoclientWrapper.__name__, func.__name__, func.func_code.co_filename, func.func_code.co_firstlineno + 1)
예제 #3
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        spentTime = time() - self.startTime
        if spentTime > self.timeLimit:
            if not IS_CLIENT and not IS_BOT:
                incrTickOverspends()
            context = self.context
            if context is None:
                context = sys._getframe(1).f_code.co_name
            checkpoints = self.checkpoints
            if checkpoints:
                startTime = self.startTime
                for checkpoint in checkpoints:
                    endTime = checkpoint[1]
                    checkpoint[1] -= startTime
                    startTime = endTime

                LOG_TIME_WARNING(spentTime, context, self.tickLength, checkpoints)
            else:
                LOG_TIME_WARNING(spentTime, context, self.tickLength)
        return