Python 2.3a2: sockettimeout() buggy?

Carsten Gaebler news at snakefarm.org
Wed Apr 16 08:53:28 EDT 2003


Hi there,

I just tried out the new socket timeouts in Python 2.3a2. Seems that the
timeout does not work if you make a file from the socket. Here's what I
tried:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', 12345))
s.listen(socket.SOMAXCONN)
(conn, addr) = s.accept()
conn.settimeout(10)


Now, when I say 'conn.recv(4096)' it raises an exception after 10 seconds
if there's no data to read as expected. But when I say:

f = conn.makefile('w+')
f.readline()

then the readline() call will raise that exception immediately. Is this a bug
or feature? Or did I miss something?

cg.




More information about the Python-list mailing list