繁体   English   中英

如何通过多处理模块的过程函数调用带有关键字参数的函数?

[英]How to call a function with keyword arguments by the process function of multiprocessing module?

如何调用此函数:

git.Repo.clone_from(git_url, repo_dir, branch=master, progress=CustomProgress())

通过多处理模块的处理功能?

在这里我使用关键字参数,所以我必须传递这个多处理模块的过程函数,我想像一个单独的过程一样被调用

P = multiprocessing.Process(target = git.Repo.clone_from, args = (git_url, repo_dir, branch=master, progress=CustomProgress())

用您的关键字args组成一个字典,并将其作为kwargs参数传递给Process对象。

P = multiprocessing.Process(target = git.Repo.clone_from, args = (git_url, repo_dir), kwargs = {"branch" : "master", "progress" : CustomProgress()})

谢谢苏拉杰。 上面的代码在语法上稍作更改后就可以正常工作:P = multiprocessing.Process(target = git.Repo.clone_from,args =(git_url,repo_dir),kwargs = {““ branch”:“ master”,“ progress”:CustomProgress( )})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM