From charlesreid1

pip3 install --pre dill

Now you can serialize objects with closures via:

dill.dumps(MyClass)
dill.dumps(function_with_closure)