Ejemplo n.º 1
0
 def wrapped_target(*args, **kwargs):
     request = DataCollector().request
     if request:
         start_time = timezone.now()
         result = target(*args, **kwargs)
         end_time = timezone.now()
         curr = request.meta_time or 0
         request.meta_time = curr + _time_taken(start_time, end_time)
     else:
         result = target(*args, **kwargs)
     return result
Ejemplo n.º 2
0
 def wrapped_target(*args, **kwargs):
     request = DataCollector().request
     if request:
         start_time = timezone.now()
         result = target(*args, **kwargs)
         end_time = timezone.now()
         curr = request.meta_time or 0
         request.meta_time = curr + _time_taken(start_time, end_time)
     else:
         result = target(*args, **kwargs)
     return result
Ejemplo n.º 3
0
 def wrapped_target(*args, **kwargs):
     request = DataCollector().request
     if request:
         start_time = timezone.now()
         result = target(*args, **kwargs)
         end_time = timezone.now()
         curr = request.meta_time or 0
         request.meta_time = curr + _time_taken(start_time, end_time)
     else:
         # Logger.error('Cant perform meta profile due to no request model in DataCollector. '
         #              'Has Silk middleware been installed properly?')
         result = target(*args, **kwargs)
     return result
Ejemplo n.º 4
0
 def wrapped_target(*args, **kwargs):
     request = DataCollector().request
     if request:
         start_time = timezone.now()
         result = target(*args, **kwargs)
         end_time = timezone.now()
         curr = request.meta_time or 0
         request.meta_time = curr + _time_taken(start_time, end_time)
     else:
         Logger.error('Cant perform meta profile due to no request model in DataCollector. '
                      'Has Silk middleware been installed properly?')
         result = target(*args, **kwargs)
     return result
Ejemplo n.º 5
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     if self._should_meta_profile:
         end_time = datetime.datetime.now()
         exception_raised = exc_type is not None
         if exception_raised:
             Logger.error('Exception when performing meta profiling, dumping trace below')
             traceback.print_exception(exc_type, exc_val, exc_tb)
         request = DataCollector().request
         if request:
             curr = request.meta_time or 0
             request.meta_time = curr + _time_taken(self.start_time, end_time)
         else:
             Logger.error('Cant perform meta profile due to no request model in DataCollector. '
                          'Has Silk middleware been installed properly?')
Ejemplo n.º 6
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     if self._should_meta_profile:
         end_time = timezone.now()
         exception_raised = exc_type is not None
         if exception_raised:
             Logger.error('Exception when performing meta profiling, dumping trace below')
             traceback.print_exception(exc_type, exc_val, exc_tb)
         request = DataCollector().request
         if request:
             curr = request.meta_time or 0
             request.meta_time = curr + _time_taken(self.start_time, end_time)
         else:
             Logger.error('Cant perform meta profile due to no request model in DataCollector. '
                          'Has Silk middleware been installed properly?')
     DataCollector().end_meta_block()