Re: POP connection timeout.

2008-05-08 Thread Aspersieman

Gabriel Genellina wrote:

Use 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(...)
Note that setdefaulttimeout applies to ALL subsequent socket operations, not 
only using poplib.


  

Fantastic! This works thanks.

Nicol

--

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle. 



--
http://mail.python.org/mailman/listinfo/python-list


Re: POP connection timeout.

2008-05-08 Thread Gabriel Genellina
En Thu, 08 May 2008 09:24:37 -0300, Aspersieman <[EMAIL PROTECTED]> escribió:

> I have written an application that queries a POP mailbox and
> 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.

Use 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(...)
Note that setdefaulttimeout applies to ALL subsequent socket operations, not 
only using poplib.


-- 
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: POP connection timeout.

2008-05-08 Thread Scott David Daniels

Aspersieman wrote:

I have written an application that queries a POP mailbox and ...

> I want to have it time out
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.


Can anyone help me implement this timeout functionality.


Obviously, get a copy of 2.5 and back-port the poplib code as
poplib25 or some such.  If you want more help than that, hire
someone to do it.

--Scott David Daniels

--
http://mail.python.org/mailman/listinfo/python-list


POP connection timeout.

2008-05-08 Thread Aspersieman

Hi All

I have written an application that queries a POP mailbox and 
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.


Can anyone help me implement this timeout functionality.

Regards

Nicol
--

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle. 






--

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle. 



--
http://mail.python.org/mailman/listinfo/python-list


POP connection timeout.

2008-05-08 Thread Aspersieman

Hi All

I am have written an application that queries a POP mailbox and 
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.


Can anyone help me implement this timeout functionality.

Regards

Nicol
--

The three things to remember about Llamas:
1) They are harmless
2) They are deadly
3) They are made of lava, and thus nice to cuddle. 



--
http://mail.python.org/mailman/listinfo/python-list