prawn-cake / vk-requests

vk.com requests for humans. API library for vk.com
MIT License
158 stars 22 forks source link

TypeError: getresponse() got an unexpected keyword argument 'buffering' #11

Closed underworlddemon closed 8 years ago

underworlddemon commented 8 years ago

log from cmd (лог командной строки) after lot of api calls (после множественных запросов)

T:\proekty\VK_api>python check.py
2016-07-03 04:16:44,940 INFO [vk-requests] Getting access token for user '***login***'
2016-07-03 04:16:44,943 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): m.vk.com
2016-07-03 04:16:45,198 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): login.vk.com
2016-07-03 04:16:45,405 INFO [vk-requests] Session is already established
2016-07-03 04:16:45,406 INFO [vk-requests] Doing oauth2
2016-07-03 04:16:45,407 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): oauth.vk.com
2016-07-03 04:16:45,543 INFO [vk-requests] Token will be expired in 0 sec.
2016-07-03 04:16:45,546 INFO [vk-requests] Done
VK user login: ***login***
VK user password:
2016-07-03 04:17:05,214 INFO [vk-requests] Getting access token for user '***login***'
2016-07-03 04:17:05,216 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): m.vk.com
2016-07-03 04:17:05,287 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): login.vk.com
2016-07-03 04:17:05,474 INFO [vk-requests] Session is already established
2016-07-03 04:17:05,475 INFO [vk-requests] Doing oauth2
2016-07-03 04:17:05,476 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): oauth.vk.com
2016-07-03 04:17:05,608 INFO [vk-requests] Token will be expired in 0 sec.
2016-07-03 04:17:05,611 INFO [vk-requests] Done
2016-07-03 04:17:05,612 INFO [requests.packages.urllib3.connectionpool] Starting
 new HTTPS connection (1): api.vk.com
...
some work of script here
than error:
...
Traceback (most recent call last):
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 376, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 378, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 1197, in getresponse
    response.begin()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\socket.py", li
ne 575, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
929, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
791, in read
    return self._sslobj.read(len, buffer)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
575, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [WinError 10054] Удаленный хост принудительно разорвал сущ
ествующее подключение

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\adapters.py", line 370, in send
    timeout=timeout
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 609, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\util\retry.py", line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\packages\six.py", line 309, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\packages\urllib3\connectionpool.py", line 378, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 1197, in getresponse
    response.begin()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\http\client.py
", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\socket.py", li
ne 575, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
929, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
791, in read
    return self._sslobj.read(len, buffer)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\ssl.py", line
575, in read
    v = self._sslobj.read(len, buffer)
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', Conn
ectionResetError(10054, 'Удаленный хост принудительно разорвал существующее подк
лючение', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "check.py", line 32, in <module>
    a=api.groups.getMembers(group_id=glists[i])
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
vk_requests\api.py", line 65, in __call__
    return self._api.make_request(request_obj=self)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
vk_requests\api.py", line 37, in make_request
    return self._session.make_request(request_obj)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
vk_requests\auth.py", line 406, in make_request
    captcha_response=captcha_response)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
vk_requests\auth.py", line 462, in send_api_request
    url=url, data=method_kwargs, timeout=vk_api.get_timeout())
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\sessions.py", line 511, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
vk_requests\utils.py", line 148, in request
    method, url, **kwargs)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\demon\AppData\Local\Programs\Python\Python35\lib\site-packages\
requests\adapters.py", line 412, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetErro
r(10054, 'Удаленный хост принудительно разорвал существующее подключение', None,
 10054, None))

T:\proekty\VK_api>

Как можно исправить ? Или хотя бы ловить до падения всего

prawn-cake commented 8 years ago

Подобную проблему уже разбирали тут. Твоя проблема это ConnectionError, по каким-то причинам vk host разрывает с тобой соединение - может ты в их black-листе, превышаешь лимит запросов (хотя там явная ошибка дается) или еще что-то.

underworlddemon commented 8 years ago

Достаточно ли будет перехватить все исключения, дабы уже собранные данные не терялись ?

prawn-cake commented 8 years ago

Чтобы данные не терялись, сохраняй их на диск. Если хочешь чтобы соединение автоматически восстанавливалось, то в таком случае лови нужные эксепшены (в данном случае похоже достаточно лишь ConnectionError) и повторяй запрос