Skip to content

Commit f60a5a9

Browse files
committed
#267 workaround Python pickle bug
* this is a workaround for a Python pickle bug that shows up indirectly in: grantjenks/python-diskcache#32 * the workaround is use a subclass of diskcache.Disk that does not use pickle.HIGHEST_PROTOCOL Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 5578839 commit f60a5a9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/scancode/cache.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,18 @@ def __init__(self, cache_dir):
8585
self.cache_scans_dir = os.path.join(self.cache_base_dir, 'scans')
8686
fileutils.create_dir(self.cache_scans_dir)
8787

88+
# workaround for https://github.com/grantjenks/python-diskcache/issues/32
89+
from diskcache import Disk
90+
class DiskWithNoHighPickleProtocol(Disk):
91+
"Subclass of diskcache.Disk that always use the lowest pickle protocol."
92+
def __init__(self, directory, size_threshold, pickle_protocol):
93+
super(DiskWithNoHighPickleProtocol, self).__init__(directory, size_threshold, pickle_protocol)
94+
self._protocol = 0
95+
8896
# and finially cache instances
8997
from diskcache import Cache
90-
self.infos = Cache(self.cache_infos_dir)
91-
self.scans = Cache(self.cache_scans_dir)
98+
self.infos = Cache(self.cache_infos_dir, disk=DiskWithNoHighPickleProtocol)
99+
self.scans = Cache(self.cache_scans_dir, disk=DiskWithNoHighPickleProtocol)
92100

93101
def scan_key(self, path, file_infos):
94102
"""

0 commit comments

Comments
 (0)