Dill serializer for Celery 4.0+
There are some issues with NameError when serialized functions depend on values defined outside of the scope of the def. Try putting imports and such inside the function definition, i.e.
def make_me_a_pi(): import math return math.pi
as opposed to
import math def make_me_a_pi(): return math.pi
which would result in NameError: name 'math' is not defined.