#33882: Allow transaction.atomic to work in async contexts. -------------------------------------+------------------------------------- Reporter: alex | Owner: | rajdesai24 Type: New feature | Status: assigned Component: Database layer | Version: 4.0 (models, ORM) | Severity: Normal | Resolution: Keywords: async | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by Hedley Roos):
I have create scripts to illustrate how the proposed solution fails under load. Django calls `close_old_connections` on every request, and I simulate it in a simpler environment so you don't have to bootstrap a whole Django. Also, it's easier to introduce load via scripts. Download the `failure_*` attachments on this ticket. Run the server script, and then the client script. You will of course need Django and requests in your Python. You should see randomly occurring connection errors. Removing the `aatomic` decorator from the server script also removes these errors, so clearly it introduces a problem. By the way, I adapted the decorator from https://stackoverflow.com/questions/74575922 /how-to-use-transaction-with-async-functions-in-django. Now, if I am misunderstanding the point of `close_old_connections`, then this entire post is moot. Please let me know if I am doing something wrong. In my particular use-case I have resorted to a horrible hack where I randomly call `close_old_connections`, instead of on every request. -- Ticket URL: <https://code.djangoproject.com/ticket/33882#comment:23> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/01070194a2cbcc65-59b2ea37-839e-4f75-b74e-1a2641e351cc-000000%40eu-central-1.amazonses.com.