El 26/10/2010 13:33, Jose Caballero escribió:




On Oct 26, 2010, at 3:15, Arnau Sanchez<pyar...@gmail.com>  wrote:

On Mon, 25 Oct 2010 19:09:04 -0400 Jose Caballero wrote:

import time
for i in range(3):
        print time.time()
        time.sleep(3)

Como bien comentaba Ricardo, aquí tenías buffering en la fuente. ¿Pero que
hubiera pasado si no hubieras podido modificar el script para poner el flush?

Una opción:

  Popen("python -u tuscript.py", ...)

Otra (requiere stdbuf):

  Popen("stdbuf -oL python tuscript.py", ...)

http://www.pixelbeat.org/programming/stdio_buffering/


Muy interesante. Muchas gracias por el apunte.


Hace algún tiempo tuve la misma necesidad, capturar el stdout y stderr de otra aplicación en tiempo real:

<http://mail.python.org/pipermail/python-es/2007-November/018739.html>

Después lo mejore un poco y solucione unos problemas que tenia, si interesa podría buscarlo, comentar el código y enviarlo aqui.

Saludos,


--
Oswaldo Hernández
_______________________________________________
Python-es mailing list
Python-es@python.org
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a