Re: [Python-Dev] timeout options in high-level networking modules

2005-12-22 Thread Jeremy Hylton
Yup.  I just went through a similar exercise with urllib2.  It wasn't
too hard to plumb through a different HTTPHandler that set the
timeout, but it would be much nicer as a default option.  It seems
like a 30 minute project; might fit in an odds and ends sprint.

Jeremy

On 12/22/05, Jim Fulton [EMAIL PROTECTED] wrote:

 Yesterday, I needed to make a web request in a program (actually a test)
 that could block indefinately, so I needed to set a socket timeout.
 Unfortunately, AFAICT none of urllib, urllib2, httplib provide options to set
 the timeout on the sockets they use.  I ended up having to roll my own
 code to make the request.

 It would be nice if high-level network modules, like the ones mentioned
 above, had options to provide a timeout.  (For example, urlopen could
 grow an optional timout argument.)

 Thoughts?

 If we think this is a good idea, then someone who has time could start 
 chipping
 away at it.  I'm happy to work on this *if* I can find time.  This would make
 a nice easy sprint project at PyCon too.

 Jim

 --
 Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
 CTO  (540) 361-1714http://www.python.org
 Zope Corporation http://www.zope.com   http://www.zope.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/jeremy%40alum.mit.edu

___
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] timeout options in high-level networking modules

2005-12-22 Thread Steve Holden
Jim Fulton wrote:
 Yesterday, I needed to make a web request in a program (actually a test)
 that could block indefinately, so I needed to set a socket timeout.
 Unfortunately, AFAICT none of urllib, urllib2, httplib provide options to set
 the timeout on the sockets they use.  I ended up having to roll my own
 code to make the request.
 
 It would be nice if high-level network modules, like the ones mentioned
 above, had options to provide a timeout.  (For example, urlopen could
 grow an optional timout argument.)
 
 Thoughts?
 
 If we think this is a good idea, then someone who has time could start 
 chipping
 away at it.  I'm happy to work on this *if* I can find time.  This would make
 a nice easy sprint project at PyCon too.
 
That's a very good idea. At present the only option one has is to set a 
global socket.defaulttimout() or somehow monkey-patch the modules you 
want to use, and neither of those options are entirely satisfactory.

Basically any method that can create a new TCP connection should acquire 
an optional timeout=None parameter, right?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006  www.python.org/pycon/

___
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] timeout options in high-level networking modules

2005-12-22 Thread Charles Cazabon
Steve Holden [EMAIL PROTECTED] wrote:
 Jim Fulton wrote:
  Yesterday, I needed to make a web request in a program (actually a test)
  that could block indefinately, so I needed to set a socket timeout.
  Unfortunately, AFAICT none of urllib, urllib2, httplib provide options to 
  set
  the timeout on the sockets they use.  I ended up having to roll my own
  code to make the request.
[...]
 That's a very good idea. At present the only option one has is to set a 
 global socket.defaulttimout() or somehow monkey-patch the modules you 
 want to use, and neither of those options are entirely satisfactory.
 
 Basically any method that can create a new TCP connection should acquire 
 an optional timeout=None parameter, right?

Yes.  

It might also be nice if the modules that rely on blocking mode being set on
sockets (basically anything using socket.ssl()) actually explicitly set that
first.  Right now, if you do socket.setdefaulttimeout() to a non-None value
and then try to use anything that does SSL (poplib, imaplib), the connections
will quickly die.

Charles
-- 
---
Charles Cazabon   [EMAIL PROTECTED]
GPL'ed software available at:   http://pyropus.ca/software/
---
___
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] timeout options in high-level networking modules

2005-12-22 Thread Jim Fulton
Steve Holden wrote:
 Jim Fulton wrote:
 
Yesterday, I needed to make a web request in a program (actually a test)
that could block indefinately, so I needed to set a socket timeout.
Unfortunately, AFAICT none of urllib, urllib2, httplib provide options to set
the timeout on the sockets they use.  I ended up having to roll my own
code to make the request.

It would be nice if high-level network modules, like the ones mentioned
above, had options to provide a timeout.  (For example, urlopen could
grow an optional timout argument.)

Thoughts?

If we think this is a good idea, then someone who has time could start 
chipping
away at it.  I'm happy to work on this *if* I can find time.  This would make
a nice easy sprint project at PyCon too.

 
 That's a very good idea. At present the only option one has is to set a 
 global socket.defaulttimout() or somehow monkey-patch the modules you 
 want to use, and neither of those options are entirely satisfactory.

Dang, I missed that. I could have abused that yesterday. :)

 Basically any method that can create a new TCP connection should acquire 
 an optional timeout=None parameter, right?

Yup, except that None shouldn't be the I didn't pass anything
marker, since None is a valid settimeout parameter.

Jim

-- 
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.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] timeout options in high-level networking modules

2005-12-22 Thread Akradiusz Miskiewicz
Charles Cazabon wrote:

 It might also be nice if the modules that rely on blocking mode being set
 on sockets (basically anything using socket.ssl()) actually explicitly set
 that
 first.  Right now, if you do socket.setdefaulttimeout() to a non-None
 value and then try to use anything that does SSL (poplib, imaplib), the
 connections will quickly die.
There is a patch for that in python patch tracking system. Just someone
needs to recheck it and apply.

 
 Charles


___
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