How to use dill library for object serialization with shelve library
问题 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