Keep transactions specific to task

This commit is contained in:
tcely 2025-03-18 20:12:54 -04:00 committed by GitHub
parent 021f4b172a
commit d2458a2979
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -230,10 +230,9 @@ def index_source_task(source_id):
media.published = published_dt
if task:
task.verbose_name = tvn_format.format(vn)
try:
with atomic():
if task:
task.save(update_fields={'verbose_name'})
try:
media.save()
log.debug(f'Indexed media: {source} / {media}')
# log the new media instances
@ -248,6 +247,7 @@ def index_source_task(source_id):
log.error(f'Index media failed: {source} / {media} with "{e}"')
if task:
task.verbose_name = verbose_name
with atomic():
task.save(update_fields={'verbose_name'})
# Tack on a cleanup of old completed tasks
cleanup_completed_tasks()