I'm trying to write some data to a cache of which some has been retrieved from a postgres db using psycopg2 and sqlalchemy. Some of them are NumericRange
instances. Unfortunately, when I try to pickle the objects before writing them to the Redis cache, they raise an exception.
lib/python2.7/copy_reg.py", line 77, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__ cannot be pickled
Is it possible to change pickle, so it can deal with NumericRange
objects? Note cpickle
is used for the serialization.