I have written an application that queries a POP mailbox andUse socket.setdefaulttimeout(timeout_in_seconds) before you create the POP3 object; this value will be used by the initial connect. Once it is connected, you can set a different timeout for retrieving mail using pop.sock.settimeout(...)
downloads messages. When the application tries to connect to the mail
server, but takes too long (eg. longer than 60 seconds) I want to have
it time out.
Something like
try:
pop = poplib.POP3(POPHOST, POPPORT)
except someerror, err:
print "Connecting to mail box has timed out:\n", err
I know that in python 2.5 I could pass an additional timeout parameter
to the above statement ( ie: pop = poplib.POP3(POPHOST, POPPORT,
TIMEOUTINSECONDS), but I am using python 2.4.
Note that setdefaulttimeout applies to ALL subsequent socket operations, not only using poplib.
<http://docs.python.org/lib/socket-objects.html>
--
Gabriel Genellina