Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure delete_expired uses writable database. #358

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions django_celery_results/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ def warn_if_repeatable_read(self):
if isolation == 'REPEATABLE-READ':
warnings.warn(TxIsolationWarning(W_ISOLATION_REP.strip()))

def database_for_write(self):
return router.db_for_write(self.model)

def connection_for_write(self):
return connections[router.db_for_write(self.model)]
return connections[self.database_for_write()]

def connection_for_read(self):
return connections[self.db]
Expand All @@ -86,7 +89,7 @@ def get_all_expired(self, expires):

def delete_expired(self, expires):
"""Delete all expired results."""
with transaction.atomic(using=self.db):
with transaction.atomic(using=self.database_for_write()):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also resolve the merge conflict please?

raw_delete(queryset=self.get_all_expired(expires))


Expand Down