Open adriaant opened 10 years ago
I believe you are overthinking this example. However, just to be certain I'll ask @aaugustin to weigh in.
I saw this comment today. I must have missed the notification.
In that example, @transaction.non_atomic_requests
ensures that with transaction.atomic()
maps to a database transaction and not just a savepoint. So the example is correct in this regard.
However, the last line # If the transaction fails
will never be reached. Only an exception can cause the transaction to fail and there's no code to handle such an exception.
Since you are using "with transaction.atomic()", the code wrapped by transaction.atomic() will only commit changes to database on success, whether you have the non_atomic_requests decorator or not. I believe that's what the docs state @ https://docs.djangoproject.com/en/1.6/topics/db/transactions/#django.db.transaction.atomic