question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't cache Page objects with redis

See original GitHub issue

I’ve ran into this trying to cache a queryset of Page models using redis as backend cache:

PicklingError at /
Can't pickle <class 'wagtail.wagtailcore.blocks.base.ChoiceBlockMeta'>: attribute lookup wagtail.wagtailcore.blocks.base.ChoiceBlockMeta failed
Request Method: GET
Request URL:    http://localhost:8111/
Django Version: 1.8.4
Exception Type: PicklingError
Exception Value:    
Can't pickle <class 'wagtail.wagtailcore.blocks.base.ChoiceBlockMeta'>: attribute lookup wagtail.wagtailcore.blocks.base.ChoiceBlockMeta failed
Exception Location: /home/vagrant/.virtualenvs/project/local/lib/python2.7/site-packages/redis_cache/cache.py in set, line 239
Python Executable:  /home/vagrant/.virtualenvs/project/bin/python
Python Version: 2.7.6
Python Path:    
['/home/vagrant/project',
 '/home/vagrant/.virtualenvs/project/lib/python2.7',
 '/home/vagrant/.virtualenvs/project/lib/python2.7/plat-i386-linux-gnu',
 '/home/vagrant/.virtualenvs/project/lib/python2.7/lib-tk',
 '/home/vagrant/.virtualenvs/project/lib/python2.7/lib-old',
 '/home/vagrant/.virtualenvs/project/lib/python2.7/lib-dynload',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-i386-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/home/vagrant/.virtualenvs/project/local/lib/python2.7/site-packages',
 '/home/vagrant/project',
 '/home/vagrant/project']
Server time:    Thu, 3 Dec 2015 14:07:16 +1300

Looks like something’s wrong with the serializer?

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:4
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
wolphcommented, Mar 19, 2018

I’ve created a “fix” which works for me without any issues, can others verify if it works properly for them?

https://github.com/wagtail/wagtail/compare/master...WoLpH:pickle-fix

1reaction
pySilvercommented, Apr 30, 2020

Nah, solution provided by @WoLpH no longer works most of the time. Issues like the following arises:

AttributeError: Can't pickle local object 'ChoiceBlock.get_callable_choices.<locals>.choices_callable'

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Redis as a Persistent Object Cache - Kinsta
Redis can be used to store values generated by WordPress' native object cache in a persistent manner so that cached objects can be...
Read more >
Enabling Redis Object Caching - Nexcess
Redis object caching is enabled by default on all new sites. We automatically install the Object Cache Pro plugin to do this. Steps...
Read more >
Troubleshoot | Object Cache (formerly Redis) | Pantheon Docs
Drupal instructs Redis to dump cached items that are CACHE_TEMPORARY (versus PERM or a specified time) when cron runs, which causes the busy...
Read more >
Issue with redis object caching - WordPress.org
I can't see any reason why this issue happens. The plugin is mostly using core functions and do not interact on the caching...
Read more >
Redis and Object Caching - WP Rocket Knowledge Base
Benefits of object caching. This can help pages that can't be page cached by WP Rocket: The backend of your WordPress site; Front-end...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found