# Which issue(s) this PR fixes We've been seeing this `AttributeError` quite frequently for quite some time ([logs](https://ops.grafana-ops.net/explore?schemaVersion=1&panes=%7B%22oPl%22:%7B%22datasource%22:%22000000193%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%7Bcluster%3D~%5C%22prod-%28eu-west-0%7Cus-central-0%29%5C%22,%20namespace%3D%5C%22amixr-prod%5C%22%7D%20%7C%3D%20%60AttributeError%28%5C%22module%20%27apps.schedules.tasks.notify_about_empty_shifts_in_schedule%27%20has%20no%20attribute%20%27apply_async%27%5C%22%60%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22000000193%22%7D,%22editorMode%22:%22code%22%7D%5D,%22range%22:%7B%22from%22:%22now-7d%22,%22to%22:%22now%22%7D%7D%7D&orgId=1)) ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
33 lines
1.4 KiB
Python
33 lines
1.4 KiB
Python
from celery.utils.log import get_task_logger
|
|
|
|
from common.custom_celery_tasks import shared_dedicated_queue_retry_task
|
|
|
|
task_logger = get_task_logger(__name__)
|
|
|
|
|
|
@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=1)
|
|
def drop_cached_ical_task(schedule_pk):
|
|
from apps.schedules.models import OnCallSchedule
|
|
from apps.schedules.tasks import refresh_ical_final_schedule
|
|
|
|
task_logger.info(f"Start drop_cached_ical_task for schedule {schedule_pk}")
|
|
try:
|
|
schedule = OnCallSchedule.objects.get(pk=schedule_pk)
|
|
schedule.drop_cached_ical()
|
|
except OnCallSchedule.DoesNotExist:
|
|
task_logger.info(f"Tried to drop_cached_ical_task for non-existing schedule {schedule_pk}")
|
|
else:
|
|
# queue a refresh for final schedule
|
|
refresh_ical_final_schedule.apply_async((schedule_pk,))
|
|
task_logger.info(f"Finish drop_cached_ical_task for schedule {schedule_pk}")
|
|
|
|
|
|
@shared_dedicated_queue_retry_task(autoretry_for=(Exception,), retry_backoff=True, max_retries=1)
|
|
def drop_cached_ical_for_custom_events_for_organization(organization_id):
|
|
from apps.schedules.models import OnCallScheduleCalendar
|
|
|
|
for schedule in OnCallScheduleCalendar.objects.filter(organization_id=organization_id):
|
|
drop_cached_ical_task.apply_async(
|
|
(schedule.pk,),
|
|
)
|
|
task_logger.info(f"drop cached ica for org_id {organization_id}")
|