timeout for urllib2.urlopen() in pre Python 2.6 versions

前端 未结 6 544
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 03:34

The urllib2 documentation says that timeout parameter was added in Python 2.6. Unfortunately my code base has been running on Python 2.5 and 2.4 platforms.

6条回答
  •  长情又很酷
    2020-12-29 04:12

    Well, the way timeout is handled in either 2.4 or 2.6 is the same. If you open the urllib2.py file in 2.6 u would see that it takes an extra argument as timeout and handles it using the socket.defaulttimeout() method as mentioned is answer 1.

    So you really need not update your urllib2.py in that case.

提交回复
热议问题