[Tutor] why "ifconfig" is alway running?

lei yang yanglei.fage at gmail.com
Sun Dec 19 12:09:52 CET 2010


On Sun, Dec 19, 2010 at 4:57 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "lei yang" <yanglei.fage at gmail.com> wrote
>
>
> def runForAWhile(cmd, secs=10):
>   print("running %s" % cmd)
>   timeout = datetime.timedelta(seconds=secs)
>   print timeout
>   proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT, shell=True)
>   status = proc.poll()
>
> You are still only checking status once outside the while loop.
>

Thanks, I make a stupid mistaking

Lei

>   start = datetime.datetime.now()
>   while (status is None and (datetime.datetime.now() - start) <
> timeout): #not timed out
>       print proc.stdout.readline() #TODO timestamp?
>       #print status
>       #print datetime.datetime.now() - start
>
>
>> I see that "status" always "!=0“  why  program  is NOT exited
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list