[Python-Dev] thread safe SMTP module

Gordon Messmer yinyang at eburg.com
Wed Mar 14 17:34:41 CET 2007


A couple of weeks ago, I posted a message titled "thread safe SMTP 
module" on python-list.  It's oddly split in the archive:

http://mail.python.org/pipermail/python-list/2007-March/429067.html
http://mail.python.org/pipermail/python-list/2007-March/429172.html

A while ago, I wrote an address validation function using smtplib.SMTP 
for use in a a threaded application.  In practice, I found that the 
application locked up rather frequently.  I scratched my head for a 
while before concluding that the caveat mentioned in the thread module's 
documentation, noting that some built-in functions may block all 
threads, was probably at fault.  I then subclassed smtplib.SMTP and 
replaced all of the blocking I/O operations with nonblocking ones, and 
the function began working properly.

After some discussion, Aahz suggested that I discuss the problem here, 
on python-dev.  He seemed to think that the problem I saw may have been 
an indication of a bug in python.  Could anyone take a look at that 
thread and say whether it looks like a bug, or working with non-blocking 
sockets was the right thing to do?


More information about the Python-Dev mailing list