2
0
mirror of https://github.com/codl/forget synced 2025-01-09 14:12:32 +01:00

add autoretries on all tasks that talk with twitter

This commit is contained in:
codl 2017-08-08 23:00:22 +02:00
parent 8a8d2cb0d3
commit 1aaebc0ce2
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A

View File

@ -72,7 +72,7 @@ def chunk_twitter_archive(archive_id):
import_twitter_archive_month.s(archive_id, filename).apply_async()
@app.task
@app.task(autoretry_for=(TwitterError, URLError))
def import_twitter_archive_month(archive_id, month_path):
ta = TwitterArchive.query.get(archive_id)
@ -129,7 +129,7 @@ def queue_deletes():
for account in eligible_accounts:
delete_from_account.s(account.id).apply_async()
@app.task
@app.task(autoretry_for=(TwitterError, URLError))
def delete_from_account(account_id):
account = Account.query.get(account_id)
latest_n_posts = db.session.query(Post.id).with_parent(account).order_by(db.desc(Post.created_at)).limit(account.policy_keep_latest)
@ -165,7 +165,7 @@ def refresh_posts(posts):
if posts[0].service == 'twitter':
return lib.twitter.refresh_posts(posts)
@app.task
@app.task(autoretry_for=(TwitterError, URLError))
def refresh_account(account_id):
account = Account.query.get(account_id)
@ -181,7 +181,7 @@ def refresh_account(account_id):
db.session.commit()
return posts
@app.task
@app.task(autoretry_for=(TwitterError, URLError))
def refresh_account_with_oldest_post():
post = Post.query.options(db.joinedload(Post.author)).order_by(db.asc(Post.updated_at)).first()
return refresh_account(post.author_id)