[Tutor] submitting batch jobs with python
Bob Gailer
ramrom@earthling.net
Mon Dec 23 16:49:14 2002
--=======60CD238D=======
Content-Type: text/plain; x-avg-checked=avg-ok-790D3F98; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit
>commands=[<list of commandlines to send>]
>output=[]
>for i in range(len(commands)):
> a=os.popen(command[i]).readlines
> output.append(a)
shorten this to:
for cmd in commands:
a=os.popen(cmd).readlines() # NOTE () after readlines!
output.append(a)
then use list comprehension to shorten it to:
output = [os.popen(cmd).readlines() for cmd in commands]
>Would each iteration of the loop occur two seconds apart
Yes.
>the loop keep going while a popen().readlines() waited for the system
>response?
To do that you'd need to use threads.
Bob Gailer
mailto:ramrom@earthling.net
303 442 2625
--=======60CD238D=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-790D3F98
Content-Disposition: inline
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.431 / Virus Database: 242 - Release Date: 12/17/2002
--=======60CD238D=======--