我有以下功能:
def copy_file(source_file, target_dir):
pass
Run Code Online (Sandbox Code Playgroud)
现在我想用来立即multiprocessing执行这个功能:
p = Pool(12)
p.map(lambda x: copy_file(x,target_dir), file_list)
Run Code Online (Sandbox Code Playgroud)
问题是,lambda不能被腌制,所以这就失败了.解决这个问题最简洁(pythonic)的方法是什么?