Opened 3 years ago

Closed 3 years ago

#33054 closed New feature (fixed)

Make captureOnCommitCallbacks capture callbacks added by callbacks

Reported by: Evgenii Morozov Owned by: Evgenii Morozov
Component: Database layer (models, ORM) Version: 3.2
Severity: Normal Keywords: on_commit
Cc: Adam Johnson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Evgenii Morozov)

Sometimes there's a need to add additional on_commit callback from on_commit callback. For example, on_commit callback saves some model, but post_save handler for that model also uses on_commit callback to perform some additional action (e.g. spawn celery task). Current Django TestCase code ignores new callbacks added during on_commit callback execution.

I present a simple solution for this problem:
https://github.com/django/django/pull/14796

Change History (7)

comment:1 by Mariusz Felisiak, 3 years ago

Cc: Adam Johnson added
Triage Stage: UnreviewedAccepted

Sounds reasonable. Thanks!

comment:2 by Adam Johnson, 3 years ago

Summary: Support post-commit hooks adding more post-commit hooksMake captureOnCommitCallbacks capture callbacks added by callbacks

comment:3 by Mariusz Felisiak, 3 years ago

Owner: changed from nobody to Evgenii Morozov
Status: newassigned

comment:4 by Mariusz Felisiak, 3 years ago

Needs documentation: set

comment:5 by Mariusz Felisiak, 3 years ago

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Evgenii Morozov, 3 years ago

Description: modified (diff)

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In d89f976b:

Fixed #33054 -- Made TestCase.captureOnCommitCallbacks() capture callbacks recursively.

Note: See TracTickets for help on using tickets.
Back to Top