Skip to content

Commit 96dfe01

Browse files
committed
Ensure export_dispatch makes new export instance
Fixes an issue where using `export_dispatch` with scheduled tasks created duplicate ExportInstance records in the DB, because the "-1" instance_pk ends up getting passed through to `delegate_batch` and the various callbacks. If `export_dispatch` creates the exporter, then it can pass the actual PK and avoid creating duplicates.
1 parent 8ac2805 commit 96dfe01

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

django/sierra/export/tasks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def export_dispatch(instance_pk, export_filter, export_type, options):
8686
"""
8787
Trigger an export from an external source.
8888
"""
89-
args = (instance_pk, export_filter, export_type, options)
89+
connections['default'].close_if_unusable_or_obsolete()
90+
exp = spawn_exporter(instance_pk, export_filter, export_type, options)
91+
args = (exp.instance.pk, exp.export_filter, exp.export_type, options)
9092
job = delegate_batch.s({}, *args, chunk_id='header')
9193
job.link_error(do_final_cleanup.s(*args, status='errors',
9294
chunk_id='error-callback'))

0 commit comments

Comments
 (0)