开发者

Python subprocess problems - order of events

开发者 https://www.devze.com 2023-04-04 20:39 出处:网络
I\'m writing some code that takes a bunch of textfiles, runs OpinionFinder on them, then analyses the results. OpinionFinder is a python program that calls a java progam to manage various other progra

I'm writing some code that takes a bunch of text files, runs OpinionFinder on them, then analyses the results. OpinionFinder is a python program that calls a java progam to manage various other programs.

I have:

some code (pull data off the web, write text files)

    args = shlex.split('python opinionfinder.py -f doclist')
    optout = subprocess.Popen(args)
    retcode = optout.wait()

some more code to analyse OpinionFinder's text files.

When I didn't have the optout.wait bit, the subprocess 开发者_如何学JAVAwould get executed after the rest of the script had finished, i.e. before the file analysis part. When I added the optout.wait OpinionFinder didn't run properly - I think because it couldn't find the files from the first part of the script - i.e. the order is wrong again.

What am I doing wrong?

What's the best way to run some script, execute an external process, then run the rest of the script?

Thanks.

0

精彩评论

暂无评论...
验证码 换一张
取 消