#36047: `BaseConnectionHandler.close_all()` doesn't work with async clients
-------------------------------------+-------------------------------------
     Reporter:  amirreza             |                    Owner:  (none)
         Type:  Bug                  |                   Status:  new
    Component:  Core (Cache system)  |                  Version:  5.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by amirreza:

Old description:

> hi
> in django.core.cache there is this code:
>
> {{{
> caches = CacheHandler()
>

> def close_caches(**kwargs):
>     # Some caches need to do a cleanup at the end of a request cycle. If
> not
>     # implemented in a particular backend cache.close() is a no-op.
>     caches.close_all()
> }}}
>
> where `CacheHandler` is a subclass of `BaseConnectionHandler`
> `close_all()` looks like this:
>
> {{{
>     def close_all(self):
>         for conn in self.all(initialized_only=True):
>             conn.close()
> }}}
>

> but when a async client is at work, `.close()` doesn't work, it needs to
> be `await conn.aclose()`
>
> note that in my case (django-valkey) there is no way for async clients to
> implement a sync method for `close`
>
> p.s: i know django doesn't fully support async cache clients, i open this
> issue so the problem doesn't get lost

New description:

 hi
 in django.core.cache there is this code:

 {{{
 caches = CacheHandler()


 def close_caches(**kwargs):
     # Some caches need to do a cleanup at the end of a request cycle. If
 not
     # implemented in a particular backend cache.close() is a no-op.
     caches.close_all()
 }}}

 where `CacheHandler` is a subclass of `BaseConnectionHandler`
 `close_all()` looks like this:

 {{{
     def close_all(self):
         for conn in self.all(initialized_only=True):
             conn.close()
 }}}


 but when an async client is at work, `.close()` doesn't work, it needs to
 be `await conn.aclose()`

 note that in my case (django-valkey) there is no way for async clients to
 implement a sync method for `close`

 p.s: i know django doesn't fully support async cache clients, i open this
 issue so the problem doesn't get lost

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36047#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 visit 
https://groups.google.com/d/msgid/django-updates/010701941e64b0eb-91289ef3-9a8b-4d22-ab48-30c6e00c86ad-000000%40eu-central-1.amazonses.com.

Reply via email to