Created
January 5, 2021 14:40
-
-
Save arajkumar/0d2fa8b42fe975027a24c26e425524ef 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
def cleanup_db_tables(self): | |
"""Cleanup RDS data tables on a periodic basis.""" | |
def clean_celery_taskmeta(): | |
num_days = os.environ.get('KEEP_DB_META_NUM_DAYS', '30') | |
self.cleanup_tables('celery_taskmeta', 'date_done', num_days) | |
def clean_worker_results() | |
num_days = os.environ.get('KEEP_WORKER_RESULT_NUM_DAYS', '30') | |
self.cleanup_tables('worker_results', 'ended_at', num_days) | |
... | |
cleanup_tables = [clean_celery_taskmeta, clean_worker_results, ] | |
for clean in cleanup_db_tables: | |
try: | |
clean() | |
except Exception as e: | |
logger.error("cleanup failed for %s with exception %r", clean.__name__, e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment