Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: d39f5f64538edd6c690fe635926063fb7cac853b authored by cvs2svn on 10 April 1995, 12:32:31 UTC
This commit was manufactured by cvs2svn to create tag 'release12'.
Tip revision: d39f5f6
test_select.py
# 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()
back to top