开发者

calling a process from python

I am calling a perl script from python. The perl script retrieves a large data set in batches from a webserver which takes time. This perl script is executed in the loop. It does the job fairly well but during the last run of the loop, while the script is still downloading, it executes the rest of the python code.

I want to know what is the best way to call another program in python, and when running the perl script, the python process to wait till the execution of the perl script finishes as the rest of the python code is processing the data downloaded. I h开发者_如何学Pythonave read about threading but not sure how to implement it in my case.

the code is

for expr in names_dict[keys]:
    subprocess.call(["./test.pl", expr, absFilePath])

Any help will be appreciated.

Many Thanks,


Use subprocess.Popen(). Check out this blog post:

http://trifoliummedium.blogspot.com/2010/12/running-command-line-with-python-and.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜