[Django] #33795: Django sync_to_async takes infinite time with asgiref==3.5.2

12 views
Skip to first unread message

Django

unread,
Jun 21, 2022, 4:27:37 AM6/21/22
to django-...@googlegroups.com
#33795: Django sync_to_async takes infinite time with asgiref==3.5.2
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
parfeniukink |
Type: Bug | Status: new
Component: | Version: 3.2
Uncategorized | Keywords: asgiref
Severity: Normal | sync_to_async
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
**Django==3.2.13
asgiref==3.5.2
**
If you will try to decorate any ORM function with sync_to_async you will
wait forever.

**asgiref==3.5.0** works fine

--
Ticket URL: <https://code.djangoproject.com/ticket/33795>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 21, 2022, 4:41:13 AM6/21/22
to django-...@googlegroups.com
#33795: Django sync_to_async takes infinite time with asgiref==3.5.2
-------------------------------------+-------------------------------------
Reporter: parfeniukink | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:
Keywords: asgiref | Triage Stage:
sync_to_async | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by parfeniukink:

Old description:

> **Django==3.2.13
> asgiref==3.5.2
> **
> If you will try to decorate any ORM function with sync_to_async you will
> wait forever.
>
> **asgiref==3.5.0** works fine

New description:

**Django==3.2.13
asgiref==3.5.2
**
If you will try to decorate any ORM function with sync_to_async you will
wait forever.

**asgiref==3.5.0** works fine


{{{
# models.py
class DTOManager(models.Manager):
@sync_to_async
def filter(self, *args, **kwargs) -> list[BaseModel]:
return [self._dto_mapper(i) for i in
self.model.objects.filter(*args, **kwargs)]

@sync_to_async
def get(self, *args, **kwargs) -> BaseModel:
try:
return self._dto_mapper(self.model.objects.get(*args,
**kwargs))
except self.model.DoesNotExist:
raise ObjectNotFound(f"{self.model.__name__} not found")

class Hotel(models.Model):
id = models.UUIDField(primary_key=True, editable=False)
coordinates = models.PointField(null=True)

dto_objects = DTOManager(dto_mapper=lambda hotel:
HotelDTO(**hotel.curated_data) if hotel else None)
objects = models.Manager()

# services.py
hotels = await Hotel.dto_objects.filter(id=12)
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33795#comment:1>

Reply all
Reply to author
Forward
0 new messages