From d24e3b37ca5d0e8e19c2d10d8b5709d74c989ea5 Mon Sep 17 00:00:00 2001 From: Denick <1049485+apie@users.noreply.github.com> Date: Wed, 9 Sep 2020 22:12:11 +0200 Subject: [PATCH] Cast memoryview objects to bytes to be able to pickle them. (#163) Fixes #125 --- cachalot/apps.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cachalot/apps.py b/cachalot/apps.py index 58088f5..87b0ab6 100644 --- a/cachalot/apps.py +++ b/cachalot/apps.py @@ -1,3 +1,4 @@ +import copyreg from django import __version__ as django__version__, VERSION as django_version from django.apps import AppConfig from django.conf import settings @@ -93,4 +94,7 @@ class CachalotConfig(AppConfig): name = 'cachalot' def ready(self): + # Cast memoryview objects to bytes to be able to pickle them. + # https://docs.python.org/3/library/copyreg.html#copyreg.pickle + copyreg.pickle(memoryview, lambda val: (memoryview, (bytes(val),))) cachalot_settings.load()