timeout and sockets example request??
Dave Brueck
dave at pythonapocrypha.com
Thu Jul 22 15:39:23 EDT 2004
Ishwar Rattan wrote:
> In section 7.2 of Python library reference manual:
>
> exception timeout
> This exception is raised when a timeout occurs on a socket which has had
> timeouts enabled via a prior call to settimeout(). The accompanying value
> is a string whose value is currently always ``timed out''. New in version 2.3.
>
> I assumed that settimeout() is an attribute of newly created socket object,
> but is not so!
What version of Python are you using? Could you post some code showing
what didn't work? Here's why I ask:
Python 2.3.4 (#53, May 25 2004, 21:17:02)...
Type "help", "copyright", "credits" or "l...
>>> from socket import *
>>> s = socket(AF_INET, SOCK_STREAM)
>>> s.settimeout(5)
>>>
(no errors)
setdefaulttimeout is handy when you don't have access to the actual
socket object, e.g.:
>>> import socket
>>> socket.getdefaulttimeout()
10.0
>>> socket.setdefaulttimeout(3)
>>> import urllib
>>> urllib.urlopen('http://www.google.com').read()
'<html><head><meta http-equiv="content-type" content=...
-Dave
More information about the Python-list
mailing list