#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>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/01070181856c35a8-74c70643-02ad-46ad-a14a-f3420ddfce10-000000%40eu-central-1.amazonses.com.

Reply via email to