New submission from Nathan Duran: The following code:
import smtplib test = smtplib.SMTP('mail.host.com') will hang the entire script for about ten minutes when run on a machine which is connected to the internet via an ISP who blocks port 25 (which is pretty much all of them these days). Closer inspection of the smtplib sources reveals that it is making use of blocking sockets, which is all well and good, but I do not believe they should be allowed to block for such a ridiculously lengthy period of time. My task is to walk the list of MX records provided by a DNS query, connect to each server listed and check a user-supplied address for validity. If I have to wait 10 minutes for an exception to be thrown for each unresponsive server, this process could easily take hours per address, which is completely unacceptable. My workaround is to ditch smtplib entirely and write my own socket code, but setting a timeout on a socket throws it into non-blocking mode, which is not entirely what I want, either. PHP allows one to apply a perfectly sane timeout to a blocking socket without any difficulty, and this is something I'm frankly rather surprised to see Python choke on. What I'd expect to see is an exception after less than a minute's worth of repeated failures so the caller can catch it and try another port. ---------- components: Library (Lib) messages: 62498 nosy: khiltd severity: normal status: open title: Blocking sockets take entirely too long to timeout type: behavior versions: Python 2.5 __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2132> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com