[Python-Dev] thread safe SMTP module

2007-03-14 Thread Gordon Messmer
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?
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] thread safe SMTP module

2007-03-14 Thread Gordon Messmer
Aahz wrote:
> 
> One small wrinkle (and the reason I suggested bringing this to
> python-dev): I suspect that the problem is not a bug, but simply the
> occasional failure of sockets.  When that happens in a threaded app
> without timeouts, eventually threads "die" (block forever).

IIRC, my whole process was locking up, not just individual threads.

Tonight I should have time to pull an old copy of the code out of CVS 
and recreate the test script that I used.  Once I have, it should be a 
matter of feeding a big list of email addresses to the script and 
waiting a couple of minutes for the script to lock up.  The last time I 
looked, the problem was very easy to observe.

___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com