Opened 7 years ago

Closed 7 years ago

#28844 closed Bug (duplicate)

Sites cache is not multi-process safe

Reported by: Bertrand Bordage Owned by: nobody
Component: contrib.sites Version: dev
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

The site cache, consisting on a dictionary, is thread safe.
However, changing the object within a process has no effect on other processes, unless you restart all processes.
Here is a minimal example.

In a first django shell:

>>> from django.contrib.sites.models import Site
>>> Site.objects.get_current()
<Site: mysite.com>

In a second one:

>>> from django.contrib.sites.models import Site
>>> site = Site.objects.get_current()
>>> site.domain = 'monsite.fr'
>>> site.save()
>>> Site.objects.get_current()
<Site: monsite.fr>

Then back in the first shell:

>>> Site.objects.get_current()
<Site: mysite.com>

The object is not changed.

I don’t think we can fix this without using cache backends. However, this caching must be disabled with the default LocMem cache, since it’s not multi-process safe.

Change History (1)

comment:1 by Tim Graham, 7 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #15894.

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