#32409: TestCase async tests are not transaction-aware
-------------------------------------+-------------------------------------
     Reporter:  David                |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Testing framework    |                  Version:  3.1
     Severity:  Normal               |               Resolution:
     Keywords:  TestCase, async,     |             Triage Stage:  Accepted
  transaction                        |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

 > I do not know if this can be achieved without an async-ready database
 client.

 Yes, That's kind of where I'm at with it. :| — This is a Difficult
 Problemâ„¢.

 In traditional request-response scenarios we can reasonably assume that
 there's a single transaction in a single thread and not worry about what
 goes on outside that. Once there are multiple threads in play you start
 wanting (that's not the right word perhaps) to think about isolation
 levels, how you'll handle conflicts and so on, and what's right in that
 space for your application (which may not be general). At the moment we're
 constrained by the ORM not having been built with any in mind at all, so
 the required safety wheels do impinge.

 For now, can you try writing this particular test with pytest-asyncio?
 That should skip the outer async_to_sync(), which should/may hopefully
 mean that the sync_to_async call is run on the outermost thread. (Without
 sitting down with the exact test and the debugger it's hard to say
 exactly.)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32409#comment:6>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/064.0ad3dfe47c696d969a2ec781c3c59c06%40djangoproject.com.

Reply via email to