bbangert / beaker

WSGI middleware for sessions and caching
https://beaker.readthedocs.org/
Other
517 stars 146 forks source link

How to specify protocol of pickle.dumps in ext.redis? #181

Open lypro09539 opened 4 years ago

lypro09539 commented 4 years ago

Hello, I use redis as cache backend. Because of different default pickle protocol in python2 and python3, data cached in service A( which use python3) cannot be resolving correctly after being retrieved in service B(use python2 environment) , and I got "unsupported pickle protocol: 3"

Would you plz help me figure out what am I supposed to do to handle this situation ? Or would it be feasible to pass 'protocol' param to RedisNamespaceManager?

amol- commented 4 years ago

Python2 doesn't support pickle protocol 3, which was introduced in Python3. There is no way to load data in Pickle3 from Python2. But you can set the pickle.DEFAULT_PROTOCOL in Python3 which will tell pickle which version of the protocol to use when saving data.

The data you already had saved in pickle3 must be migrated back to pickle2 btw.