Merge pull request #169 from codl/fix-deadlock

disable autoflush in refresh_posts, fixing deadlocks. closes GH-19
This commit is contained in:
codl 2019-03-11 03:18:58 +01:00 committed by GitHub
commit 1430361763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 14 deletions

View File

@ -160,7 +160,9 @@ def refresh_posts(posts):
api = get_api_for_acc(acc)
new_posts = list()
with db.session.no_autoflush:
for post in posts:
print('Refreshing {}'.format(post))
try:
status = api.status(post.mastodon_id)
new_post = db.session.merge(

View File

@ -234,7 +234,7 @@ def delete_from_account(account_id):
Post.query.with_parent(account, 'posts')
.filter(Post.created_at + account.policy_keep_younger <= db.func.now())
.filter(~Post.id.in_(db.select((latest_n_posts.c.id, )))).order_by(
db.func.random()).limit(100).with_for_update().all())
db.func.random()).limit(100).all())
to_delete = None