Skip to content

Celery Scheduled Tasks Documentation

This document describes the periodic tasks configured in celery.py.

Important: Changes to Waffle switches or Django settings that affect task scheduling require a container restart to take effect. The periodic task configuration is evaluated once when the Celery worker starts.

Task Queues

The following queues are configured:

QueuePurpose
emailEmail-related tasks
longrunningDefault queue for long-running tasks
dataimportData import tasks
dataexportData export tasks

Waffle Switches

The following Waffle switches control task scheduling:

Switch NameDescription
enable_periodic_tasksMaster switch that enables all periodic tasks (except queue health checks)
epa_sep_scrapedEnables EPA SEP scraped data import task
workflow-automation-enabledEnables the workflow manager task

Scheduled Tasks

Always Active (No Switch Required)

These tasks run regardless of the enable_periodic_tasks switch:

Queue Health Checks

TaskIntervalQueueCondition
queue_health_check_taskEvery 2 minutesemailRequires WORKER_EMAIL_QUEUE_TEST_URL setting
queue_health_check_taskEvery 30 minuteslongrunningRequires WORKER_LONGRUNNING_QUEUE_TEST_URL setting

Requires enable_periodic_tasks Switch

All tasks below require the enable_periodic_tasks Waffle switch to be active.

Virus Scanning

TaskIntervalSource
check_virus_scan_completeEvery 2 minutesdata_uploads.tasks
check_downloadable_virus_scan_completeEvery 30 secondsdata_downloads.tasks

Image Processing

TaskIntervalSource
check_images_and_processEvery hourrasters.tasks

Backups

TaskIntervalSource
backup_taskWeekly (every 7 days)backups.tasks

Notifications

TaskIntervalSource
send_pending_notificationsEvery 60 secondsnotifications.tasks

Data Import Tasks (Daily at 8:00 AM)

TaskScheduleConditionSource
import_emit_data8:00 AM dailyRequires AWS_NASA_EMIT_STORAGE_BUCKET_NAME settingdata_import.tasks
import_edf_methaneair_data8:00 AM dailyRequires DATA_IMPORT_S3_ACCESS_KEY_ID settingdata_import.tasks
import_unep_data8:00 AM dailyAlways (when periodic tasks enabled)data_import.tasks
import_carbonmapper_data8:00 AM dailyAlways (when periodic tasks enabled)data_import.tasks
import_californiasmp_data8:00 AM dailyAlways (when periodic tasks enabled)data_import.tasks
import_epa_sep_scraped_data8:00 AM dailyRequires epa_sep_scraped switchdata_import.tasks
import_carbonmapper_scenes8:15 AM dailyAlways (when periodic tasks enabled)data_import.tasks

Non-Detect Calculations

TaskScheduleSource
recalculate_non_detects8:30 AM daily (modified only)nondetects.tasks
recalculate_non_detects (full)6:30 AM every 2 daysnondetects.tasks

EPA SEP

TaskScheduleSource
send_epa_reminders12:00 PM dailyepa_sep.tasks

User Management

TaskScheduleSource
remove_old_temporary_usersEvery 2 hourscustom_auth.tasks

Infrastructure

TaskScheduleSource
try_matching_orphan_imagesMidnight dailyinfrastructure.tasks

Auditing

TaskScheduleSource
audit_emission_matching_runsEvery 15 minutesemission_matching.tasks
audit_data_import_runsEvery 15 minutesdata_import.tasks

Workflows

TaskScheduleConditionSource
run_workflow_managerEvery 5 minutesRequires workflow-automation-enabled switchworkflows.tasks

Sensor Data

TaskScheduleSource
remove_old_sensor_data_requests12:30 AM dailysensor_data.tasks

Conditional Schedule Summary

Settings-Based Conditions

SettingTasks Affected
WORKER_EMAIL_QUEUE_TEST_URLEmail queue health check
WORKER_LONGRUNNING_QUEUE_TEST_URLLongrunning queue health check
AWS_NASA_EMIT_STORAGE_BUCKET_NAMEEMIT data import
DATA_IMPORT_S3_ACCESS_KEY_IDEDF MethaneAir data import

Switch-Based Conditions

SwitchTasks Affected
enable_periodic_tasksAll tasks except queue health checks
epa_sep_scrapedEPA SEP scraped data import
workflow-automation-enabledWorkflow manager

Applying Changes

To apply changes to switches or settings that affect scheduling:

  1. Update the Waffle switch in Django admin or the setting in target environment
  2. Restart the Celery worker container for changes to take effect

The setup_periodic_tasks function runs once during worker initialization via the @app.on_after_finalize.connect decorator, so runtime changes to switches or settings will not affect the schedule until the worker is restarted.