Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#15337 closed (worksforme)

cyclic import dependency when extend builtin backend

Reported by: yi.codeplayer@… Owned by: nobody
Component: Core (Cache system) Version: 1.3-beta
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by russellm)

When writing a custom cache backend which inherit from django's builtin memcache backend, say

    from django.core.cache.backends.memcached import CacheClass as BaseCacheClass
    class MyCache(BaseCacheClass):

and set backend to "mycache.MyCache" in, then and import each other.
Turn object to be a SimpleLazyObject would solve this problem.

Attachments (1)

cache.patch (180 bytes) - added by yi.codeplayer@… 6 years ago.

Download all attachments as: .zip

Change History (5)

Changed 6 years ago by yi.codeplayer@…

comment:1 Changed 6 years ago by russellm

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

Can't reproduce -- I dropped a custom cache class defined as you describe, and don't the problem you describe. Looking at the code, I can't even work out what set of conditions would allow this to be reproduced -- I don't see any circular dependency. memcached doesn't import anything from the django.core.cache.

comment:2 Changed 6 years ago by anonymous

  • Resolution worksforme deleted
  • Status changed from closed to reopened

You need to config this custom backend to the default cache backend in to reproduce this problem, django.core.cache would import the default cache backend.
sorry for poor english description.

comment:3 Changed 6 years ago by russellm

  • Resolution set to worksforme
  • Status changed from reopened to closed

And that's exactly what I did. If you want to convince me, you'll need to provide a sample project.

comment:4 Changed 6 years ago by anonymous

I was wrong, there's no bug in django ;-)

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