IO timeout in threaded application

G

Gordon Messmer

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?
 
A

Aahz

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?

If you don't mind having the same timeout for every socket, use either
timeoutsocket.py (or the new functionality in Python 2.3) to set a
global timeout.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top