Checklist
Steps to reproduce
Wrap a view that errors with @non_atomic_requests, but use a transaction around it somehow. The easiest way is to test it from a Django TestCase, which uses transactions around each test. Another way would be to have a custom middleware that does a transaction a different way.
Expected behavior
rest_framework.set_rollback should not call transaction.set_rollback because the view is declared as non-atomic.
Actual behavior
rest_framework.set_rollback calls transaction.set_rollback. Its check for "is this view non-atomic" checks connection.in_atomic_block which as indicated above can be true for a number of reasons.
Checklist
masterbranch of Django REST framework.Steps to reproduce
Wrap a view that errors with
@non_atomic_requests, but use a transaction around it somehow. The easiest way is to test it from a DjangoTestCase, which uses transactions around each test. Another way would be to have a custom middleware that does a transaction a different way.Expected behavior
rest_framework.set_rollbackshould not calltransaction.set_rollbackbecause the view is declared as non-atomic.Actual behavior
rest_framework.set_rollbackcallstransaction.set_rollback. Its check for "is this view non-atomic" checksconnection.in_atomic_blockwhich as indicated above can be true for a number of reasons.