#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):

 The suggested async atomic decorator does work in my use cases, but
 because the code has no tests, I cannot fully trust it. Incidentally, the
 decirator with `thread_sensitive=True` fails under high load. I can
 simulate that failure locally.

 As for common use cases for async transaction support:

 1. Distributed row-level lock through `select_for_update`. Crucial for
 financial systems.
 2. transaction.on_commit for comms to external systems. This can be as
 simple as sending a task to Celery on a successful commit.
 3. A method where we modify X related objects needs to be atomic.

 Django is very nearly there with full async support. I use Connexion |
 FastAPI + Django + Flutter as a toolchain, because Django has the best ORM
 by far, and many other best in class features. I wish I understood the
 async transactional part a bit better, then I would gladly jump in and fix
 this. As it is I'm hoping that the person who wrote the original
 transaction management can jump in here and help us.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/33882#comment:22>
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/010701949db78602-15ead854-725f-44f1-95f8-9d0caa670eca-000000%40eu-central-1.amazonses.com.

Reply via email to