mirror of
https://github.com/python/cpython.git
synced 2024-11-24 10:24:35 +08:00
ae3b3a33d8
reduce) * ftplib.py: added default callback for retrlines; added dir() method * ftplib.py: don't return self in self.connect(); added hack so that if 'CDUP' is not understood, 'CWD ..' is tried. * ftplib.py: second method called init() should have been called connect(); if __init__ sees more than one argument, it will also try to login().
24 lines
500 B
Python
24 lines
500 B
Python
# Testing select module
|
|
|
|
def test():
|
|
import select
|
|
import os
|
|
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do date; sleep 3; done'
|
|
p = os.popen(cmd, 'r')
|
|
for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
|
|
print 'timeout =', tout
|
|
rfd, wfd, xfd = select.select([p], [], [], tout)
|
|
print rfd, wfd, xfd
|
|
if (rfd, wfd, xfd) == ([], [], []):
|
|
continue
|
|
if (rfd, wfd, xfd) == ([p], [], []):
|
|
line = p.readline()
|
|
print `line`
|
|
if not line:
|
|
print 'EOF'
|
|
break
|
|
continue
|
|
print 'Heh?'
|
|
|
|
test()
|