[issue2132] Blocking sockets take entirely too long to timeout

Martin v. Löwis report at bugs.python.org
Sun Feb 17 21:19:38 CET 2008


Martin v. Löwis added the comment:

I recommend that you stay with non-blocking sockets, and use select/poll
on all sockets. Then you can simultaneously check multiple servers, and
select will tell you which ones you got connected to. For this
application, putting a time-out on the socket and doing the connections
sequentially seems unreasonable - that's exactly what select was
invented for.

I don't understand the "setting a timeout ... is not entirely what I
want, either" remark. The only way to specify a timeout for connect *is*
to set it into non-blocking mode. I'm sure PHP does the same.

If you want to see timeouts for smtplib, a work-around is to set a
global timeout for all sockets, through socket.setdefaulttimeout. This
will transparently apply to smtplib as well.

----------
nosy: +loewis

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2132>
__________________________________


More information about the Python-bugs-list mailing list