并行python及其子进程
我正在尝试使用并行Python(pp)模块构建集群。 我已经设置了集群。节点可用:并行python及其子进程,python,python-2.7,subprocess,parallel-python,Python,Python 2.7,Subprocess,Parallel Python,我正在尝试使用并行Python(pp)模块构建集群。 我已经设置了集群。节点可用: ./ppserver.py -p 35000 -i 127.0.0.1 -s "mysecret" 还配置了master,并提交了作业: ppservers=("node-1:35000", "node-2:35000") job_server = pp.Server(ppservers=ppservers, secret="mysecret") f1 = job_server.submit(SomeFunc
./ppserver.py -p 35000 -i 127.0.0.1 -s "mysecret"
还配置了master,并提交了作业:
ppservers=("node-1:35000", "node-2:35000")
job_server = pp.Server(ppservers=ppservers, secret="mysecret")
f1 = job_server.submit(SomeFunction, argus1), modules=('subprocess',))
f2 = job_server.submit(SomeFunction, argus2), modules=('subprocess',))
a = f2()
b = f1()
某些功能:
def SomeFunction(argus):
proc = subprocess.check_output(['python',
'~/path/to/python_script.py',
'--argu1', argus[0],
'--argu2', argus[1],
])
return proc
python_script.py与youtube api对话并将数据写入mysql数据库
在执行时,我遇到以下错误:
An error has occured during the function execution
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/ppworker.py", line 90, in run
__result = __f(*__args)
File "<string>", line 16, in SomeFunction
File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['python', '~/path/to/python_script.py', '--argu1', 'argu1', '--argu2', 'argu2']' returned non-zero exit status 2
函数执行期间发生错误
回溯(最近一次呼叫最后一次):
文件“/usr/local/lib/python2.7/dist-packages/ppworker.py”,第90行,运行中
__结果=\uu f(*\uu参数)
文件“”,第16行,在SomeFunction中
文件“/usr/lib/python2.7/subprocess.py”,第574行,在check_输出中
引发被调用的进程错误(retcode,cmd,output=output)
subprocess.CalledProcessError:命令“['python','~/path/to/python_script.py','--argu1','argu1','--argu2',argu2']”返回非零退出状态2
python\u script.py
已完全调试,知道吗?这是因为您的路径包含一个~
,默认情况下不会展开
2种解决方法:
- 添加
参数以运行shell(不推荐)shell=True
- 最佳方法:使用
os.path.expanduser
proc = subprocess.check_output(['python',
os.path.expanduser('~/path/to/python_script.py'),
'--argu1', 'argu1',
'--argu2', 'argu2',