469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

IO timeout in threaded application

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?
Jul 18 '05 #1
1 1387
In article <ma**********************************@python.org >,
Gordon Messmer <gm******@real.com> wrote:

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.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/

This is Python. We don't care much about theory, except where it intersects
with useful practice. --Aahz
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Adrian Casey | last post: by
reply views Thread by Ganbold | last post: by
8 posts views Thread by Joe Abou Jaoude | last post: by
3 posts views Thread by fluxent | last post: by
reply views Thread by George Sakkis | last post: by
10 posts views Thread by Atul Shukla | last post: by
3 posts views Thread by Jd | last post: by
14 posts views Thread by =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.