IO timeout in threaded application

Gordon Messmer gmessmer at real.com
Mon Aug 11 15:15:58 EDT 2003


According to the "signal" documentation, threads spawned as part of a 
multi-threaded application can not receive signals.

I have a daemon which I want to validate email addresses by connecting 
to the MX for the domain and sending the EHLO/MAIL/RCPT commands.  I 
would like to place an upper limit on the amount of time spent doing the 
validation.  I had expected to be able to schedule an alarm() in a 
thread, and use that to interrupt the otherwise blocking read/writes.

What's the easiest way to accomplish that?  Should I just subclass 
smtplib's SMTP class and override the "connect" function with one that 
creates a socket with a timeout?






More information about the Python-list mailing list