from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import

from celery import task

from django.core.files.storage import default_storage


@task(bind=True, max_retries=15, default_retry_delay=2)
def wait_for_default_storage_file(self, filename):
    if default_storage.exists(filename):
        return filename
    else:
        self.retry()

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import

from celery import task

from django.core.files.storage import default_storage


@task(bind=True, max_retries=15, default_retry_delay=2)
def wait_for_default_storage_file(self, filename):
    if default_storage.exists(filename):
        return filename
    elif self.request.retries < self.max_retries:
        self.retry()
    else:
        return None

Send RSVP email even if PDF doesn't exist
Send RSVP email even if PDF doesn't exist

If the PDF can't be found on the disk after the maximum number of
retries, return None, instead of raising an exception. This ensures that
the RSVP email notification still sends even without the PDF attachment.

Refs #1655

  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import division
  from __future__ import absolute_import
  
  from celery import task
  
  from django.core.files.storage import default_storage
  
  
  @task(bind=True, max_retries=15, default_retry_delay=2)
  def wait_for_default_storage_file(self, filename):
      if default_storage.exists(filename):
          return filename
+     elif self.request.retries < self.max_retries:
+         self.retry()
      else:
-         self.retry()
+         return None
  
Send RSVP email even if PDF doesn't exist
## Code Before:
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import

from celery import task

from django.core.files.storage import default_storage


@task(bind=True, max_retries=15, default_retry_delay=2)
def wait_for_default_storage_file(self, filename):
    if default_storage.exists(filename):
        return filename
    else:
        self.retry()

## Instruction:
Send RSVP email even if PDF doesn't exist
## Code After:
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import

from celery import task

from django.core.files.storage import default_storage


@task(bind=True, max_retries=15, default_retry_delay=2)
def wait_for_default_storage_file(self, filename):
    if default_storage.exists(filename):
        return filename
    elif self.request.retries < self.max_retries:
        self.retry()
    else:
        return None
