def check_celery(app_configs, **kwargs): errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( Error( "Celery is configured in the eager mode", hint=get_doc_url("admin/install", "celery"), id="weblate.E005", )) elif settings.CELERY_BROKER_URL == "memory://": errors.append( Critical( "Celery is configured to store queue in local memory", hint=get_doc_url("admin/install", "celery"), id="weblate.E026", )) else: if is_celery_queue_long(): errors.append( Critical( "The Celery tasks queue is too long, either the worker " "is not running or is too slow.", hint=get_doc_url("admin/install", "celery"), id="weblate.E009", )) result = ping.delay() try: result.get(timeout=10, disable_sync_subtasks=False) except TimeoutError: errors.append( Critical( "The Celery does not process tasks or is too slow " "in processing them.", hint=get_doc_url("admin/install", "celery"), id="weblate.E019", )) except NotImplementedError: errors.append( Critical( "The Celery is not configured to store results, " "CELERY_RESULT_BACKEND is probably not set.", hint=get_doc_url("admin/install", "celery"), id="weblate.E020", )) heartbeat = cache.get("celery_heartbeat") loaded = cache.get("celery_loaded") now = time.time() if loaded and now - loaded > 60 and (not heartbeat or now - heartbeat > 600): errors.append( Critical( "The Celery beats scheduler is not executing periodic tasks " "in a timely manner.", hint=get_doc_url("admin/install", "celery"), id="weblate.C030", )) return errors
def check_celery(app_configs, **kwargs): errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( weblate_check("weblate.E005", "Celery is configured in the eager mode", Error)) elif settings.CELERY_BROKER_URL == "memory://": errors.append( weblate_check( "weblate.E026", "Celery is configured to store queue in local memory")) else: if is_celery_queue_long(): errors.append( weblate_check( "weblate.E009", "The Celery tasks queue is too long, either the worker " "is not running, or is too slow.", )) result = ping.delay() try: pong = result.get(timeout=10, disable_sync_subtasks=False) # Check for outdated Celery running different version of configuration if ping() != pong: errors.append( weblate_check( "weblate.E034", "The Celery process is outdated, please restart it.", )) except TimeoutError: errors.append( weblate_check( "weblate.E019", "The Celery does not process tasks, or is too slow " "in processing them.", )) except NotImplementedError: errors.append( weblate_check( "weblate.E020", "The Celery is not configured to store results, " "CELERY_RESULT_BACKEND is probably not set.", )) heartbeat = cache.get("celery_heartbeat") loaded = cache.get("celery_loaded") now = time.time() if loaded and now - loaded > 60 and (not heartbeat or now - heartbeat > 600): errors.append( weblate_check( "weblate.C030", "The Celery beat scheduler is not executing periodic tasks " "in a timely manner.", )) return errors
def check_celery(app_configs, **kwargs): errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( Error( 'Celery is configured in the eager mode', hint=get_doc_url('admin/install', 'celery'), id='weblate.E005', )) elif settings.CELERY_BROKER_URL == 'memory://': errors.append( Critical( 'Celery is configured to store queue in local memory', hint=get_doc_url('admin/install', 'celery'), id='weblate.E026', )) else: stats = get_queue_stats() if stats['celery'] > 50 or stats['search'] > 10000: errors.append( Critical( 'The Celery tasks queue is too long, either the worker ' 'is not running or is too slow.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E009', )) result = ping.delay() try: result.get(timeout=10, disable_sync_subtasks=False) except TimeoutError: errors.append( Critical( 'The Celery does not process tasks or is too slow ' 'in processing them.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E019', )) except NotImplementedError: errors.append( Critical( 'The Celery is not configured to store results, ' 'CELERY_RESULT_BACKEND is probably not set.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E020', )) heartbeat = cache.get('celery_heartbeat') if not heartbeat or time.time() - heartbeat > 600: errors.append( Critical( 'The Celery beats scheduler is not executing periodic tasks ' 'in a timely manner.', hint=get_doc_url('admin/install', 'celery'), id='weblate.C030', )) return errors
def check_celery(app_configs, **kwargs): errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( Error( 'Celery is configured in the eager mode', hint=get_doc_url('admin/install', 'celery'), id='weblate.E005', ) ) else: if get_queue_length() > 50 or get_queue_length('search') > 10000: errors.append( Critical( 'The Celery tasks queue is too long, either the worker ' 'is not running or is too slow.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E009', ) ) result = ping.delay() try: result.get(timeout=10, disable_sync_subtasks=False) except TimeoutError: errors.append( Critical( 'The Celery does not process tasks or is too slow ' 'in processing them.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E019', ) ) except NotImplementedError: errors.append( Critical( 'The Celery is not configured to store results, ' 'CELERY_RESULT_BACKEND is probably not set.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E020', ) ) return errors
def check_celery(app_configs, **kwargs): errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( Error( 'Celery is configured in the eager mode', hint=get_doc_url('admin/install', 'celery'), id='weblate.E005', ) ) else: if get_queue_length() > 50 or get_queue_length('search') > 10000: errors.append( Critical( 'The Celery tasks queue is too long, either the worker ' 'is not running or is too slow.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E009', ) ) result = ping.delay() try: result.get(timeout=10, disable_sync_subtasks=False) except TimeoutError: errors.append( Critical( 'The Celery does not process tasks or is too slow ' 'in processing them.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E019', ) ) except NotImplementedError: errors.append( Critical( 'The Celery is not configured to store results, ' 'CELERY_RESULT_BACKEND is probably not set.', hint=get_doc_url('admin/install', 'celery'), id='weblate.E020', ) ) return errors
def check_celery(app_configs, **kwargs): # Import this lazily to avoid evaluating settings too early from weblate.utils.tasks import ping errors = [] if settings.CELERY_TASK_ALWAYS_EAGER: errors.append( weblate_check("weblate.E005", "Celery is configured in the eager mode", Error)) elif settings.CELERY_BROKER_URL == "memory://": errors.append( weblate_check( "weblate.E026", "Celery is configured to store queue in local memory")) else: if is_celery_queue_long(): errors.append( weblate_check( "weblate.E009", "The Celery tasks queue is too long, either the worker " "is not running, or is too slow.", )) result = ping.delay() try: pong = result.get(timeout=10, disable_sync_subtasks=False) current = ping() # Check for outdated Celery running different version of configuration if current != pong: if pong is None: # Celery runs Weblate 4.0 or older differing = ["version"] else: differing = [ key for key, value in current.items() if key not in pong or value != pong[key] ] errors.append( weblate_check( "weblate.E034", "The Celery process is outdated or misconfigured." " Following items differ: {}".format( ", ".join(differing)), )) except TimeoutError: errors.append( weblate_check( "weblate.E019", "The Celery does not process tasks, or is too slow " "in processing them.", )) except NotImplementedError: errors.append( weblate_check( "weblate.E020", "The Celery is not configured to store results, " "CELERY_RESULT_BACKEND is probably not set.", )) heartbeat = cache.get("celery_heartbeat") loaded = cache.get("celery_loaded") now = time.time() if loaded and now - loaded > 60 and (not heartbeat or now - heartbeat > 600): errors.append( weblate_check( "weblate.C030", "The Celery beat scheduler is not executing periodic tasks " "in a timely manner.", )) return errors