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

riquito at gmail.com riquito at gmail.com
Wed Jun 14 17:13:04 CEST 2006


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




More information about the Python-list mailing list