def endpoints_expire(): """ This celery task removes all endpoints that have not been recently updated :return: """ function = f"{__name__}.{sys._getframe().f_code.co_name}" task_id = None if celery.current_task: task_id = celery.current_task.request.id log_data = { "function": function, "message": "endpoints expire", "task_id": task_id, } if task_id and is_task_active(function, task_id, None): log_data["message"] = "Skipping task: Task is already active" current_app.logger.debug(log_data) return current_app.logger.debug(log_data) try: cli_endpoints.expire(2) # Time in hours except SoftTimeLimitExceeded: log_data["message"] = "endpoint expire: Time limit exceeded." current_app.logger.error(log_data) sentry.captureException() metrics.send("celery.timeout", "counter", 1, metric_tags={"function": function}) return metrics.send(f"{function}.success", "counter", 1) return log_data
def endpoints_expire(): """ This celery task removes all endpoints that have not been recently updated :return: """ function = f"{__name__}.{sys._getframe().f_code.co_name}" log_data = { "function": function, "message": "endpoints expire", } current_app.logger.debug(log_data) cli_endpoints.expire(2) # Time in hours red.set(f'{function}.last_success', int(time.time())) metrics.send(f"{function}.success", 'counter', 1)