Delete a CrontabSchedule if no PeriodicTasks reference it.
(crontab_schedule)
| 194 | |
| 195 | |
| 196 | def _cleanup_orphaned_crontab(crontab_schedule): |
| 197 | """Delete a CrontabSchedule if no PeriodicTasks reference it.""" |
| 198 | if crontab_schedule is None: |
| 199 | return |
| 200 | if PeriodicTask.objects.filter(crontab=crontab_schedule).exists(): |
| 201 | return |
| 202 | logger.debug(f"Cleaning up orphaned CrontabSchedule {crontab_schedule.id}") |
| 203 | crontab_schedule.delete() |
no test coverage detected