Asynchronous background processes in Python?

后端 未结 1 1483
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 12:32

I have been using this as a reference, but not able to accomplish exactly what I need: Calling an external command in Python

I also was reading this: http://www.pyth

相关标签:
1条回答
  • 2020-12-09 12:52

    Don't use shell=True. It will needlessy invoke the shell to call your svn program, and that will give you the shell's return code instead of svn's.

    repos = ['/repo1', '/repo2', '/repo3']
    # launch 3 async calls:
    procs = [subprocess.Popen(['svn', 'update', repo]) for repo in repos]
    # wait.
    for proc in procs:
        proc.wait()
    # check for results:
    if any(proc.returncode != 0 for proc in procs):
        print 'Something failed'
    
    0 讨论(0)
提交回复
热议问题