Opened 3 days ago

Closed 33 hours ago

#36047 closed Bug (invalid)

`BaseConnectionHandler.close_all()` doesn't work with async clients

Reported by: amirreza Owned by:
Component: Core (Cache system) Version: 5.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by amirreza)

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

Change History (3)

comment:1 by amirreza, 3 days ago

Description: modified (diff)

comment:2 by Tim Graham, 39 hours ago

Is this ticket actionable before Django supports async cache clients?

comment:3 by Sarah Boyce, 33 hours ago

Resolution: invalid
Status: newclosed

Agreed, as we don't have support for async clients, this isn't a valid bug. I will link this to #33573 as I believe this was raised to be informational

Note: See TracTickets for help on using tickets.
Back to Top