Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-12-30 Thread Django
#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
-+-
Changes (by Julien Enselme):

 * cc: Julien Enselme (added)


-- 
Ticket URL: 
Django 
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/0107018cbae5bcb6-d412148d-dcdf-457f-b4be-4b2f26a5dbcf-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-11-11 Thread Django
#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
-+-
Changes (by Tyson Clugg):

 * cc: Tyson Clugg (added)


-- 
Ticket URL: 
Django 
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/0107018bbe536104-f760e9d3-4aed-41d2-8ef2-d33771aa2cc4-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-09-28 Thread Django
#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
-+-
Changes (by moritz89):

 * cc: moritz89 (added)


-- 
Ticket URL: 
Django 
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/0107018adc245f3b-f5f66edb-ca95-4ba7-a377-f1211c9688eb-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-09-23 Thread Django
#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 Mike Lissner):

 I'm quite bad at async things generally, but I thought I'd chime in to say
 that I'm surprised async atomic transactions aren't more of a priority. A
 few of the comments above seem to imply that this isn't an important
 feature or that it's an antipattern (maybe?).

 I just turned down part of a PR where a developer is converting our code
 to async because to do so required that we drop the @transaction.atomic
 decorator. I said,  "Sorry, we can't covert this to async because given
 the choice between correctness and performance, I have to choose
 correctness."

 Am I missing something big — Isn't this a big gap in Django's support for
 real applications converting fully to async?

 Thanks all, sorry I don't have more to add! If I were better at async, I'd
 take a crack at actually fixing it.

-- 
Ticket URL: 
Django 
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/0107018ac31c9484-ac7bfdba-b162-4a66-9c61-ad67076ba611-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-02-19 Thread Django
#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
-+-
Changes (by rajdesai24):

 * cc: rajdesai24 (added)


-- 
Ticket URL: 
Django 
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/0107018669f7e31a-65288cf6-7440-41fa-8d81-01a51a5956ae-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-02-17 Thread Django
#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 rajdesai24):

 I made a new class called Async Atomic and used it as a context decorator,
 which worked but you still need to use the sync_to_async

-- 
Ticket URL: 
Django 
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/010701866159d14f-9d51b721-6cd4-4c3b-81f3-8afe145cf7e4-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-02-17 Thread Django
#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 rajdesai24):

 Hey guys, I wanted to get your suggestion on this as I had been working on
 this and testing it out


 {{{
 class AsyncAtomic:
 def __init__(self, using=None, savepoint=True, durable=True):
 self.using = using
 self.savepoint = savepoint
 self.durable = durable

 async def __aenter__(self):
 self.atomic = transaction.Atomic(self.using, self.savepoint,
 self.durable)
 await sync_to_async(self.atomic.__enter__)()
 return self.atomic

 async def __aexit__(self, exc_type, exc_value, traceback):
 await sync_to_async(self.atomic.__exit__)(exc_type, exc_value,
 traceback)


 }}}

 


 {{{
 class AsyncAtomicTestCase(TestCase):
 async def test_atomic(self):
 async with AsyncAtomic():
 # Create a new object within the transaction
 await sync_to_async(SimpleModel.objects.create)(
 field=4,
 created=datetime(2022, 1, 1, 0, 0, 0),
 )
 # Verify that the object was created within the transaction
 count = await sync_to_async(SimpleModel.objects.count)()
 self.assertEqual(count, 1)


 }}}

-- 
Ticket URL: 
Django 
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/010701866158b2ce-4c87f345-5dc3-4a32-ab06-6f21dfe92bb1-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2023-02-17 Thread Django
#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
-+-
Changes (by rajdesai24):

 * owner:  nobody => rajdesai24
 * status:  new => assigned


-- 
Ticket URL: 
Django 
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/010701866153af52-bf14ea8a-72b2-43ac-a770-ce038b20356a-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2022-12-07 Thread Django
#33882: Allow transaction.atomic to work in async contexts.
-+-
 Reporter:  alex |Owner:  nobody
 Type:  New feature  |   Status:  new
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 Heraldo Lucena):

 I opened an issue at the channels repo
 https://github.com/django/channels/issues/1937 related to this.

 The use case is not rare, it's pretty common on an async codebase. As you
 know, async code requires new API definitions on new namespaces, sync
 (blocking) and async code can't be mixed. Actually Django forces you to
 run the full transaction block inside @sync_to_async decorated functions,
 the async API becomes useless, you can't reuse any async code.

-- 
Ticket URL: 
Django 
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/01070184eea25105-1cdb96f7-5ea5-46ae-891f-4604013f670d-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2022-12-04 Thread Django
#33882: Allow transaction.atomic to work in async contexts.
-+-
 Reporter:  alex |Owner:  nobody
 Type:  New feature  |   Status:  new
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
-+-
Changes (by Hugo Osvaldo Barrera):

 * cc: Hugo Osvaldo Barrera (added)


-- 
Ticket URL: 
Django 
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/01070184dc725587-48de88d7-8742-410f-adac-1c5f37ff487e-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts.

2022-08-02 Thread Django
#33882: Allow transaction.atomic to work in async contexts.
-+-
 Reporter:  alex |Owner:  nobody
 Type:  New feature  |   Status:  new
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
-+-
Description changed by Tim Graham:

Old description:

> Wouldn't it be possible to add something like:
>
> __aenter__ = sync_to_async(Atomic.__enter__, thread_sensitive=True)
> __aexit__ = sync_to_async(Atomic.__exit__, thread_sensitive=True)
>
> to the Atomic class to support async calls?

New description:

 Wouldn't it be possible to add something like:
 {{{ #!python
 __aenter__ = sync_to_async(Atomic.__enter__, thread_sensitive=True)
 __aexit__ = sync_to_async(Atomic.__exit__, thread_sensitive=True)
 }}}
 to the Atomic class to support async calls?

--

-- 
Ticket URL: 
Django 
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/010701825f0f399e-416dff1f-7ac5-4b10-b93a-9abf5e1718f7-00%40eu-central-1.amazonses.com.


Re: [Django] #33882: Allow transaction.atomic to work in async contexts. (was: async transaction.atomic)

2022-08-02 Thread Django
#33882: Allow transaction.atomic to work in async contexts.
-+-
 Reporter:  alex |Owner:  nobody
 Type:  New feature  |   Status:  new
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
-+-

-- 
Ticket URL: 
Django 
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/010701825d9f6f94-a4238ff2-af09-410d-8d86-02677001c38f-00%40eu-central-1.amazonses.com.