5
我試圖做使用的urllib2文件的異步下載,但沒有成功地找到了插座(或它的fileno),以等待新數據的HTTP請求。這是我已經嘗試過的。找插座urllib2.urlopen返回值HTTP
>>> from urllib2 import urlopen
>>> from select import select
>>> r = urlopen('http://stackoverflow.com/')
>>> select([r], [], [])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/socket.py", line 307, in fileno
return self._sock.fileno()
AttributeError: HTTPResponse instance has no attribute 'fileno'
>>> r.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/socket.py", line 307, in fileno
return self._sock.fileno()
AttributeError: HTTPResponse instance has no attribute 'fileno'
>>> r.fp.fileno()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/socket.py", line 307, in fileno
return self._sock.fileno()
AttributeError: HTTPResponse instance has no attribute 'fileno'
>>> select([r.fp], [], [])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/socket.py", line 307, in fileno
return self._sock.fileno()
AttributeError: HTTPResponse instance has no attribute 'fileno'
>>>
謝謝,先生! –
應該提出一個錯誤,如果沒有的話。 –
http://bugs.python.org/issue1327971。它實際上看起來是你爲此提供修復的人嗎? – agf