def __form_stage_from_function( init, work ) :
ret = {}
dict_ = {'init' : init, 'work' : work}
try: # Python 3
code = {'init' : init.__code__, 'work' : work.__code__}
except AttributeError: # Python 2
code = {'init' : init.func_code, 'work' : work.func_code}
ret['object'] = dict_
ret['python'] = code
try :
marshaled = marshal.dumps(code)
except ValueError:
marshaled = None
try :
import dill
dilled = dill.dumps(code)
except ImportError:
dilled = None
ret['dill'] = dilled
ret['marshal'] = marshaled
return ret
评论列表
文章目录