Re: [Python-Dev] Time-out in URL Open

2006-07-05 Thread Facundo Batista
2006/7/4, Guido van Rossum [EMAIL PROTECTED]:

  This affect all the sockets.

 So, assuming your app is single-threaded, set the timeout, call
 urlopen(), and reset the timeout to None.

No, it's multithreaded, :D


  And I hit the problem when servicing
  information with a web service (TCPServer), and I need to timeout the
  connection of the URLOpen *only*.

 That's not so easy even if you were to have a timeout parameter to
 urlopen(). You'd have to implement that peculiarity in all the layers
 (in this case, urllib and httplib; and possibly ftplib, gopherlib etc.
 :-)

Yes, it's not SO easy, because, as you said, you have to dig into the
layers until you hit the actual socket creation and modify the timeout
for that socket only.

That's why I think that this should be handled in the standard library
and not left to implement to whoever will need it, :)

-- 
.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-05 Thread Guido van Rossum
OK, you've convinced me. Now where's that SF patch you were promising? :-)

--Guido

On 7/5/06, Facundo Batista [EMAIL PROTECTED] wrote:
 2006/7/4, Guido van Rossum [EMAIL PROTECTED]:

   This affect all the sockets.
 
  So, assuming your app is single-threaded, set the timeout, call
  urlopen(), and reset the timeout to None.

 No, it's multithreaded, :D


   And I hit the problem when servicing
   information with a web service (TCPServer), and I need to timeout the
   connection of the URLOpen *only*.
 
  That's not so easy even if you were to have a timeout parameter to
  urlopen(). You'd have to implement that peculiarity in all the layers
  (in this case, urllib and httplib; and possibly ftplib, gopherlib etc.
  :-)

 Yes, it's not SO easy, because, as you said, you have to dig into the
 layers until you hit the actual socket creation and modify the timeout
 for that socket only.

 That's why I think that this should be handled in the standard library
 and not left to implement to whoever will need it, :)

 --
 .Facundo

 Blog: http://www.taniquetil.com.ar/plog/
 PyAr: http://www.python.org/ar/
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/guido%40python.org



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-05 Thread Alex Martelli
What about doing it with a per-thread-timeout in TLS (overriding the
global one if a thread does have it set in its TLS)?  Not as clean,
but perhaps far easier to implement than patching dozens of
modules/functions/classes to provide timeout= options everywhere...


Alex


On 7/5/06, Guido van Rossum [EMAIL PROTECTED] wrote:
 OK, you've convinced me. Now where's that SF patch you were promising? :-)

 --Guido

 On 7/5/06, Facundo Batista [EMAIL PROTECTED] wrote:
  2006/7/4, Guido van Rossum [EMAIL PROTECTED]:
 
This affect all the sockets.
  
   So, assuming your app is single-threaded, set the timeout, call
   urlopen(), and reset the timeout to None.
 
  No, it's multithreaded, :D
 
 
And I hit the problem when servicing
information with a web service (TCPServer), and I need to timeout the
connection of the URLOpen *only*.
  
   That's not so easy even if you were to have a timeout parameter to
   urlopen(). You'd have to implement that peculiarity in all the layers
   (in this case, urllib and httplib; and possibly ftplib, gopherlib etc.
   :-)
 
  Yes, it's not SO easy, because, as you said, you have to dig into the
  layers until you hit the actual socket creation and modify the timeout
  for that socket only.
 
  That's why I think that this should be handled in the standard library
  and not left to implement to whoever will need it, :)
 
  --
  .Facundo
 
  Blog: http://www.taniquetil.com.ar/plog/
  PyAr: http://www.python.org/ar/
  ___
  Python-Dev mailing list
  Python-Dev@python.org
  http://mail.python.org/mailman/listinfo/python-dev
  Unsubscribe: 
  http://mail.python.org/mailman/options/python-dev/guido%40python.org
 


 --
 --Guido van Rossum (home page: http://www.python.org/~guido/)
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/aleaxit%40gmail.com

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-05 Thread skip

Guido OK, you've convinced me. Now where's that SF patch you were
Guido promising? :-)

A starting point is probably the patch Georg referred to a couple days ago:

Georg There was one patch that did this: http://python.org/sf/723312.

Alas, it's assigned to me and I let it get so stale that Martin asked the
author to update it for 2.5 a couple months ago.

Skip
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-05 Thread Nick Craig-Wood
Alex Martelli [EMAIL PROTECTED] wrote:
  What about doing it with a per-thread-timeout in TLS (overriding the
  global one if a thread does have it set in its TLS)?  Not as clean,
  but perhaps far easier to implement than patching dozens of
  modules/functions/classes to provide timeout= options everywhere...

Yes please!

I wrote a sketch of a module which did this on c.l.py recently

  
http://groups.google.com/group/comp.lang.python/browse_thread/thread/d897c00b67cadca5/fd2ceb4e014de7ce?lnk=stq=TimeoutErrorrnum=2hl=en#fd2ceb4e014de7ce

It would be much better if it had help from the core though.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-04 Thread Georg Brandl
[EMAIL PROTECTED] wrote:
 Facundo I need a timeout in urlopen, just to be able to make:
 
  urllib2.urlopen(http://no.host.org;, timeout=2)
 
 Facundo This is actually not possible, but I'll make it work.
 
 Facundo I want to know, please, if this is useful in general, for me to
 Facundo post a patch in SF.
 
 As others have posted, yes, it would be useful for 2.6.  However, you should
 consider how that might be applied to the other Internet service modules
 (ftplib, telnetlib, urllib, etc).

There was one patch that did this: http://python.org/sf/723312.

Georg

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-04 Thread Facundo Batista
2006/7/3, Guido van Rossum [EMAIL PROTECTED]:

 To fake things like this, socket.setdefaulttimeout() was added, though
 I don't know if it actually works. Have you tried that?

This affect all the sockets. And I hit the problem when servicing
information with a web service (TCPServer), and I need to timeout the
connection of the URLOpen *only*.

Regards,

-- 
.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-04 Thread Guido van Rossum
On 7/4/06, Facundo Batista [EMAIL PROTECTED] wrote:
 2006/7/3, Guido van Rossum [EMAIL PROTECTED]:

  To fake things like this, socket.setdefaulttimeout() was added, though
  I don't know if it actually works. Have you tried that?

 This affect all the sockets.

So, assuming your app is single-threaded, set the timeout, call
urlopen(), and reset the timeout to None.

 And I hit the problem when servicing
 information with a web service (TCPServer), and I need to timeout the
 connection of the URLOpen *only*.

That's not so easy even if you were to have a timeout parameter to
urlopen(). You'd have to implement that peculiarity in all the layers
(in this case, urllib and httplib; and possibly ftplib, gopherlib etc.
:-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Time-out in URL Open

2006-07-03 Thread Facundo Batista
I need a timeout in urlopen, just to be able to make:

 urllib2.urlopen(http://no.host.org;, timeout=2)

This is actually not possible, but I'll make it work.

I want to know, please, if this is useful in general, for me to post a
patch in SF.

Regards,

-- 
.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread Fred L. Drake, Jr.
On Monday 03 July 2006 14:07, Facundo Batista wrote:
  I want to know, please, if this is useful in general, for me to post a
  patch in SF.

It seems like something that should be easy, and lots of people need to 
consider this for applications.


  -Fred

-- 
Fred L. Drake, Jr.   fdrake at acm.org
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread Martin v. Löwis
Facundo Batista wrote:
 urllib2.urlopen(http://no.host.org;, timeout=2)
 
 This is actually not possible, but I'll make it work.
 
 I want to know, please, if this is useful in general, for me to post a
 patch in SF.

While it might be useful, it can only be added to Python 2.6 now.
So take your time with that patch.

Regards,
Martin
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread Guido van Rossum
To fake things like this, socket.setdefaulttimeout() was added, though
I don't know if it actually works. Have you tried that?

--Guido

On 7/3/06, Facundo Batista [EMAIL PROTECTED] wrote:
 I need a timeout in urlopen, just to be able to make:

  urllib2.urlopen(http://no.host.org;, timeout=2)

 This is actually not possible, but I'll make it work.

 I want to know, please, if this is useful in general, for me to post a
 patch in SF.

 Regards,

 --
 .Facundo

 Blog: http://www.taniquetil.com.ar/plog/
 PyAr: http://www.python.org/ar/
 ___
 Python-Dev mailing list
 Python-Dev@python.org
 http://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: 
 http://mail.python.org/mailman/options/python-dev/guido%40python.org



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread skip

Facundo I need a timeout in urlopen, just to be able to make:

 urllib2.urlopen(http://no.host.org;, timeout=2)

Facundo This is actually not possible, but I'll make it work.

Facundo I want to know, please, if this is useful in general, for me to
Facundo post a patch in SF.

As others have posted, yes, it would be useful for 2.6.  However, you should
consider how that might be applied to the other Internet service modules
(ftplib, telnetlib, urllib, etc).

Skip
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread skip

Guido To fake things like this, socket.setdefaulttimeout() was added,
Guido though I don't know if it actually works. Have you tried that?

I'm pretty sure it does, but is a rather blunt instrument for the task, as
it affects all socket connections the app might make.

Skip
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Time-out in URL Open

2006-07-03 Thread John J Lee
On Mon, 3 Jul 2006, Guido van Rossum wrote:

 To fake things like this, socket.setdefaulttimeout() was added, though
 I don't know if it actually works. Have you tried that?
[...]

It works.  I think there's some issue with SSL, though (can't seem to find 
the issue now).

Of course, feeding through the timeout to the individual protocol modules 
would be a good thing.


John

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com