select.select question

Timothy O'Malley timo at alum.mit.edu
Tue Aug 27 06:28:16 CEST 2002


hola.

Most often, you should NOT set the socket to
non-blocking when using select.select()

See

   http://www.timo-tasi.org/python/timeoutsocket.py

for simple timeout mechanisms with sockets.  Look
forward to Python 2.3, where these timeouts will be 
built in.

timO


brueckd at tbye.com wrote:
 > On Mon, 26 Aug 2002, Greg Ewing wrote:
 > 
 > > > 	# Set nonblocking and initialize data.
 > > >         self.request.setblocking(0)
 > > 
 > > 
 > > You shouldn't be making the socket non-blocking. Select
 > > will return immediately for a non-blocking socket,
 > > whether there's data there or not.
 > 
 > I don't think this is true. This code:
 > 
 > import select
 > from socket import *
 > s = socket(AF_INET, SOCK_STREAM)
 > s.connect(('www.google.com', 80))
 > s.setblocking(0)
 > select.select([s],[],[],1.0)
 > 
 > pauses for one second before returning on both my Linux box and my WinXP 
 > box.
 > 
 > -Dave
 > 
 > P.S. Thanks for making Pyrex!
 > 
 >



More information about the Python-list mailing list