Last active
August 29, 2015 14:01
-
-
Save faraocious/a9b926cde3e379b8a4eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrapper.retry(max_retries=max_retries, countdown=countdown, exc=exc) | |
AttributeError: 'function' object has no attribute 'retry' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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