prog1 | prog2 . How not to make prog2 block if not piped?

imcs ee imcsee at gmail.com
Wed Jun 14 19:28:16 CEST 2006


do u really need read something even when you run the scripts2.py directly?
why not just change script2.py to
 #script2.py
if __name__ == "__main__":
    x=sys.stdin.read()
    print 'passed'
else:
    print 'passed from else branch'

is it what  you want? or anything i misunderstand.

On 14 Jun 2006 08:13:04 -0700, riquito at gmail.com <riquito at gmail.com> wrote:
> I googled around, but couldn't understand how to solve this problem.
> I have 2 scripts
>
> # script1.py #
> print 'something'
>
> #script2.py
> x=sys.stdin.read()
> print 'passed'
>
> if I run
> script1.py | script2.py
> all goes well.
>
> But if I run just
> script2.py
> the program blocks waiting forever for input.
>
> On *nix I used select.select to solve this problem, but on windows?
> I read that maybe I should use, from win32api, GetStdHandle and
> WaitForMultipleObjects, but how to do it it's far from my knowledge.
>
> Any help?
>
> Thank you,
> Riccardo
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list