blob: f1853087f295d78072cbc377a91da5b573f51dbe [file] [log] [blame]
Guido van Rossumb31c7f71993-11-11 10:31:23 +00001# Testing select module
2
Guido van Rossumb31c7f71993-11-11 10:31:23 +00003def test():
4 import select
5 import os
6 cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do date; sleep 3; done'
7 p = os.popen(cmd, 'r')
8 for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
9 print 'timeout =', tout
10 rfd, wfd, xfd = select.select([p], [], [], tout)
11 print rfd, wfd, xfd
12 if (rfd, wfd, xfd) == ([], [], []):
13 continue
14 if (rfd, wfd, xfd) == ([p], [], []):
15 line = p.readline()
16 print `line`
17 if not line:
18 print 'EOF'
19 break
20 continue
21 print 'Heh?'
22
23test()