[Python-Dev] OK to lower timeout for test_timeout's testConnectTimeout test?

Tim Peters tim.peters at gmail.com
Fri Aug 6 03:22:28 CEST 2004


[Brett Cannon]
> That's weird because if I do the test with sock.settimeout(0.0) ...

That's very different.  If you set the socket timeout to exactly 0,
Python never calls select().  If you set it to anything > 0, Python
does call select(), but may truncate the timeout to exactly 0 in order
to call select.

> and then sock.connect(('www.google.com', 80)) I get::
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<string>", line 1, in connect
> socket.error: (36, 'Operation now in progress')
>
> But if I do the exact same thing (new socket, etc.) after closing the
> previous one but with sock.settimeout(0.00000001) I get::
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<string>", line 1, in connect
> socket.timeout: timed out

It will all be obvious <wink> if you read sock_connect().  In
particular, the message you got there is produced by

	if (timeout) {
		PyErr_SetString(socket_timeout, "timed out");
		return NULL;
	}

and you'll find that it's impossible for that to trigger if you set
the socket timeout to exactly 0.  I'd call that a bug, except it's not
worth anyone's time to fix ...


More information about the Python-Dev mailing list