Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example 6.7 does not need decorator #74

Open
adriaant opened this issue May 5, 2014 · 2 comments
Open

Example 6.7 does not need decorator #74

adriaant opened this issue May 5, 2014 · 2 comments

Comments

@adriaant
Copy link

adriaant commented May 5, 2014

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

@pydanny
Copy link
Member

pydanny commented Apr 9, 2015

I believe you are overthinking this example. However, just to be certain I'll ask @aaugustin to weigh in.

@aaugustin
Copy link

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.

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

No branches or pull requests

3 participants