def wrapper(*args, **kwargs): trigger_time = time.time() try: rv = func(*args, **kwargs) except Return as e: metric.labels(*labels).observe(time.time() - trigger_time) raise e return rv
def accumulate(iterable, func=operator.add): """ Iterate over running totals, ie [a,b,c,d] -> func( func( func(a, b), c), d) with each func result yielded. Func is operator.add by default. >>> list(accumulate([1,2,3,4,5])) [1, 3, 6, 10, 15] >>> list(accumulate([1,2,3,4,5], operator.mul)) [1, 2, 6, 24, 120] :param iterable: Iterable :param func: method (default=operator.add) to call for each pair of (last call result or first item, next item) :return generator: Generator """ it = iter(iterable) try: total = next(it) except StopIteration: return yield total for element in it: total = func(total, element) yield total
def wrapper(*args, **kwargs): trigger_time = time.time() rv = func(*args, **kwargs) metric.labels(*labels).observe(time.time() - trigger_time) return rv
def wrapper(self, *args, **kwargs): if self.executor_config.get("DEBUG", False): logger.debug("Executor %s DEBUG set, not calling 'stop_builder()'", self.name) return return func(self, *args, **kwargs)
def _thread_safe_func(*args, **kwargs): key = cachetools.keys.hashkey(*args, **kwargs) with lock_dict[key]: return func(*args, **kwargs)