0
突然我從我的代碼中得到以下錯誤,前一段時間它運行得很好。是否由互聯網連接引起?Errno 101網絡無法訪問
#Get data checkpoint size
url = 'http://url:8080/vrio/blk'
r = requests.get(url)
data = r.json()
def counterVolume_one():
wanted = {'Bytes_Written', 'Bytes_Written', 'IO_Operation'}
for d in data['Block Devices'].itervalues():
values = {k: v for k, v in d.iteritems() if k in wanted}
print json.dumps(values)
Traceback (most recent call last):
File "hyper.py", line 31, in <module>
r = requests.get(url)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 378, in send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='http://url', port=8080): Max retries exceeded with url: /vrio/blk (Caused by <class 'socket.error'>: [Errno 101] Network is unreachable)
該代碼將不會運行。請發佈導致錯誤的確切代碼。此外,無法訪問網絡通常指向網絡問題或主機名錯誤。 –
這是完整的代碼,實際上前三行產生的錯誤代碼的下一部分我無法測試,因爲我無法訪問網絡 – Imo