smtplib timeout

Stuart D. Gathman stuart at bmsi.com
Tue Jul 25 12:00:18 EDT 2006


I am doing SMTP callbacks in a Python milter
(http://pymilter.sourceforge.net) using the smtplib module.  For some
spammer MXes, it takes days (!) before smtplib.sendmail will return. 
Since the spammer connects to us every few seconds, this quickly leads to
a problem :-)

I need to set a timelimit for the operation of
smtplib.sendmail.  It has to be thread based, because pymilter uses
libmilter which is thread based.  There are some cookbook recipies which
run a function in a new thread and call Thread.join(timeout).  This
doesn't help, because although the calling thread gets a nice timeout
exception, the thread running the function continues to run.  In fact, the
problem is worse, because even more threads are created.

-- 
	      Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc.  Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.




More information about the Python-list mailing list