win32pipe

Chui Tey teyc at bigfoot.com
Fri Jun 9 04:50:58 EDT 2000


Hi,

Still trying to grapple with pipes in windows

Why does the following fragment hang on me?

#
# testwinpipe.py
#
def setuptest():
    f=open('C:\\test.txt','w')
    for i in range(50):
        f.write( str(i) + '\n')
    f.close()

def testpopen2():
    from win32pipe import popen2
    from win32pipe import popen
    cmd = 'more C:\\test.txt'
    w,r = popen2(cmd)
    magic=23
    for i in range(30):
        line = r.readline()[:-1]
        print 'i=%d'%i, line
        if i == magic:
            # send a space when more
            # waits for kb input
            w.write(' ')
    w.close()
    r.close()

if __name__ == '__main__':
    setuptest()
    testpopen2()

Thanks.

Chui





More information about the Python-list mailing list