[Tutor] Time Controlled Execution

Mike Bell ternary at gmail.com
Mon Feb 21 23:58:57 CET 2005


On Windows it looks like msvcrt will give you a non-blocking terminal
read -- on mac / *nix systems it looks a little trickier:

http://mail.python.org/pipermail/pythonmac-sig/2004-February/010140.html

The os module in windows doesn't even have O_NONBLOCK.  That seems like trouble.
m



On Sun, 20 Feb 2005 20:55:40 +0530, Varun Soundararajan
<s.varun at gmail.com> wrote:
> Hi,
> I want to know how to do this:
> I have an executable file, which reads input from stdin provided
> output at stdout or stderr.
> I have to run it for a specific period of time (say 5 secs), get the
> output and display it.
> If i use popen(), this way:
> from subprocess import *
> p = Popen(["test","<test.in"," >test.out"], shell=True)
> p.wait()
> print p.stdin,p.stdout
> I dont get output in p.stdout.Apart from this, can u say how to stop
> this subprocess after 5 secs (or whatever time frame specified)?
> signal SIGALRM may not work (as i want it to work in windows & unix).
> -Varun
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list