command line - Run programmes in a sequence using python -
this question has answer here:
i have python programme below
import os import subprocess m in range(0,10): os.chdir("c:/") run="my command%d"%m subprocess.popen(run).wait()
where 'my command' used launch programme. although have wait() after popen, turns out 10 programmes still run simultaneously, not expected. how settle issue?
two options:
- use
subprocess.check_call()
(which should run sequentially) - use
popen.communicate()
( https://docs.python.org/2/library/subprocess.html#subprocess.popen.communicate)stdout
,stderr
setsubprocess.pipe
see if stdout , stderr indeed sequentially generated
also, datetime.datetime.now()
gives microsecond, can see time granularity higher 1s.
Comments
Post a Comment