I'm using PyMemoize library to cache coroutine. I decorated the coroutine, but when Python calls it, I get:
TypeError: can't pickle coroutine objects
This happens because PyMemoize internally tries to pickle coroutine and store it inside Redis. For this, it uses shelve.Shelf, which in turn uses pickle. The problem is that, by unknown reason, pickle doesn't support pickling coroutines.
I've tried to pickle coroutines with dill and it worked. How do I tell shelve to use dill as serialization backend?
I've tried to monkey-patch shelve, but it didn't work (I don't know why):
import shelve
from dill import Pickler, Unpickler
shelve.Pickler = Pickler
shelve.Unpickler = Unpickler