Skip to content

Make part_of_a_transaction stricter about callbacks#155

Merged
meshy merged 5 commits into
mainfrom
meshy/disallow-nesting-part-of-transaction
May 1, 2026
Merged

Make part_of_a_transaction stricter about callbacks#155
meshy merged 5 commits into
mainfrom
meshy/disallow-nesting-part-of-transaction

Conversation

@meshy
Copy link
Copy Markdown
Collaborator

@meshy meshy commented May 1, 2026

There are two main improvements here:

  1. Callbacks registered during part_of_a_transaction will no longer pollute the test's transaction, and run the risk of being executed later.
  2. part_of_a_transaction will now raise an error if it detects unhandled callbacks when it starts.

Fixes #131

meshy and others added 4 commits May 1, 2026 15:53
Before this change, after-commit callbacks would pollute the transaction
in which tests run, and would sometimes be run by later code.

This change wipes the list of after-commit callbacks from the connection
before `part_of_a_transaction` completes.

Co-authored-by: Lily <code@lilyf.org>
The test util `part_of_a_transaction` didn't raise errors when dangling
callbacks were detected in the same way in which `transaction` does.

It is now strict in the same way, and shares the same setting to silence the error,
`settings.SUBATOMIC_CATCH_UNHANDLED_AFTER_COMMIT_CALLBACKS_IN_TESTS`.

Co-authored-by: Lily <code@lilyf.org>
This function can raise an error, but that was not previously documented.

Co-authored-by: Lily <code@lilyf.org>
@meshy meshy force-pushed the meshy/disallow-nesting-part-of-transaction branch from 1528006 to 9bd91c6 Compare May 1, 2026 15:04
@meshy meshy marked this pull request as ready for review May 1, 2026 15:04
@meshy meshy requested a review from a team as a code owner May 1, 2026 15:04
@meshy meshy merged commit e78e6ef into main May 1, 2026
8 checks passed
@meshy meshy deleted the meshy/disallow-nesting-part-of-transaction branch May 1, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

part_of_a_transaction should clear after-commit actions

2 participants