diff --git a/django_celery_results/backends/database.py b/django_celery_results/backends/database.py index 7353bc6f..b2778f4a 100644 --- a/django_celery_results/backends/database.py +++ b/django_celery_results/backends/database.py @@ -194,6 +194,8 @@ def _forget(self, task_id): def cleanup(self): """Delete expired metadata.""" + if not self.expires: + return self.TaskModel._default_manager.delete_expired(self.expires) self.GroupModel._default_manager.delete_expired(self.expires)