Skip to content

Instantly share code, notes, and snippets.

@faraocious
Last active August 29, 2015 14:01
Show Gist options
  • Save faraocious/a9b926cde3e379b8a4eb to your computer and use it in GitHub Desktop.
Save faraocious/a9b926cde3e379b8a4eb to your computer and use it in GitHub Desktop.
wrapper.retry(max_retries=max_retries, countdown=countdown, exc=exc)
AttributeError: 'function' object has no attribute 'retry'
from main.celery import app
def retryable(func):
countdown = 30
max_retries = 3
@wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except OperationalError as exc:
logger.error('CAUGHT EXCEPTION [ %s:%s ]: RETRYING...' % (exc.__class__.__name__, exc))
wrapper.retry(max_retries=max_retries, countdown=countdown, exc=exc)
return wrapper
@app.task
@decorator
def my_func():
return 'hi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment