[Tutor] Time Controlled Execution

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Mon Feb 21 16:06:51 CET 2005


I really don't think you can have a common way to do this on both 
systems. First, the way to kill a process is quite different on both 
systems (the os.kill function works only on UNIX systems, and I don't 
know is there is such a function available in Python for MS Windows). 
Then, I really doubt the use of pipes will work on Windows ... In our 
labs, there was some tries to port UNIX program using pipes under 
Windows and bidirectionnal pipes did not work at all and were thus 
abandonned.

But try googling for some package doing something similar. If you get 
any answer, don't forget to warn the list :)

Pierre

Varun Soundararajan a écrit :
> 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
> 

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68


More information about the Tutor mailing list