IO timeout in threaded application

Discussion in 'Python' started by Gordon Messmer, Aug 11, 2003.

  1. 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?
    Gordon Messmer, Aug 11, 2003
    #1
    1. Advertising

  2. Gordon Messmer

    Aahz Guest

    In article <>,
    Gordon Messmer <> 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 () <*> http://www.pythoncraft.com/

    This is Python. We don't care much about theory, except where it intersects
    with useful practice. --Aahz
    Aahz, Aug 11, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF1bA==?=

    how to wait for object with single threaded application

    =?Utf-8?B?UGF1bA==?=, Nov 10, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    3,120
    =?Utf-8?B?UGF1bA==?=
    Nov 10, 2004
  2. Mustafa Demirhan
    Replies:
    0
    Views:
    291
    Mustafa Demirhan
    Nov 9, 2004
  3. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,261
    Brian Candler
    Oct 6, 2004
  4. Robert Williams
    Replies:
    1
    Views:
    94
    Gary Wright
    Nov 6, 2007
  5. Bryan Richardson

    Non-Threaded Timeout?

    Bryan Richardson, Aug 8, 2008, in forum: Ruby
    Replies:
    29
    Views:
    206
    ara.t.howard
    Aug 12, 2008
Loading...

Share This Page