Changes between Version 1 and Version 2 of Ticket #35245, comment 4
- Timestamp:
- Feb 23, 2024, 2:10:41 AM (9 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #35245, comment 4
v1 v2 1 [https://github.com/LuisGMM/django_bug/blob/a43fb2584c7a15ecd2ada16b9f90fe1df7fe841c/project/app/providers/base.py#L8] 1 Tried to write a UT in [https://github.com/django/django/blob/b9d539cca79d8100b24b30fabdb21d10154634ec/tests/async/test_async_queryset.py] based on OP's case: [https://github.com/LuisGMM/django_bug/blob/a43fb2584c7a15ecd2ada16b9f90fe1df7fe841c/project/app/providers/base.py#L8] . 2 2 {{{#!python 3 items_lists = await asyncio.gather(*[MyProvider().get()]) # blocked 4 items_lists = await asyncio.gather(MyModel.objects.afirst()) # blocked 5 items_lists = await asyncio.gather(MyModel.objects.acreate()) # blocked 6 items_lists = await MyModel.objects.afirst() # works 7 items_lists = await MyModel.objects.acreate() # works 8 items_lists = await MyProvider().get() # works 3 async def test_afirst_gather(self): 4 instance = await asyncio.gather(*[SimpleModel.objects.afirst()]) 5 self.assertEqual(instance[0], self.s1) 6 7 instance = await asyncio.gather(SimpleModel.objects.filter(field=4).afirst()) 8 self.assertIsNone(instance[0]) 9 9 }}} 10 It's indeed a weird issue 10 This UT works fine so I think the issue is not related to asyncio.gather and async ORM call.