Opened 3 months ago

Closed 3 months 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 Changed 3 months ago by Mariusz Felisiak

Cc: Adam Johnson added
Triage Stage: UnreviewedAccepted

Sounds reasonable. Thanks!

comment:2 Changed 3 months ago by Adam Johnson

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

comment:3 Changed 3 months ago by Mariusz Felisiak

Owner: changed from nobody to Evgenii Morozov
Status: newassigned

comment:4 Changed 3 months ago by Mariusz Felisiak

Needs documentation: set

comment:5 Changed 3 months ago by Mariusz Felisiak

Needs documentation: unset
Triage Stage: AcceptedReady for checkin

comment:6 Changed 3 months ago by Evgenii Morozov

Description: modified (diff)

comment:7 Changed 3 months ago by Mariusz Felisiak <felisiak.mariusz@…>

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