Ошибка "Connection aborted" / "socket.timeout" при попытке выгрузить любой большой файл (> 3GB)
saippuakauppias opened this issue · 1 comments
saippuakauppias commented
Уже долгое время пытаюсь использовать данный пакет, но каждый раз валится ошибка:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1065, in _send_output
self.send(chunk)
File "/usr/lib/python3.6/http/client.py", line 986, in send
self.sock.sendall(data)
File "/usr/lib/python3.6/ssl.py", line 975, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.6/ssl.py", line 944, in send
return self._sslobj.write(data)
File "/usr/lib/python3.6/ssl.py", line 642, in write
return self._sslobj.write(data)
socket.timeout: The write operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/lib/python3/dist-packages/six.py", line 692, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1065, in _send_output
self.send(chunk)
File "/usr/lib/python3.6/http/client.py", line 986, in send
self.sock.sendall(data)
File "/usr/lib/python3.6/ssl.py", line 975, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.6/ssl.py", line 944, in send
return self._sslobj.write(data)
File "/usr/lib/python3.6/ssl.py", line 642, in write
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write operation timed out',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ydsk.py", line 24, in <module>
y.upload(args.path_from, args.path_to, overwrite=False)
File "/usr/local/lib/python3.6/dist-packages/yadisk/yadisk.py", line 327, in upload
functions.upload(self.get_session(), path_or_file, dst_path, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/yadisk/functions/resources.py", line 465, in upload
auto_retry(attempt, n_retries, retry_interval)
File "/usr/local/lib/python3.6/dist-packages/yadisk/utils.py", line 87, in auto_retry
raise e
File "/usr/local/lib/python3.6/dist-packages/yadisk/utils.py", line 84, in auto_retry
return func()
File "/usr/local/lib/python3.6/dist-packages/yadisk/functions/resources.py", line 461, in attempt
with contextlib.closing(session.put(link, data=file, **temp_kwargs)) as response:
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 578, in put
return self.request('PUT', url, data=data, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out',))
Как воспроизвести:
apt install pigz
# не 'if=/dev/zero' (!)
dd if=/dev/urandom of=testfile.tmp count=300 bs=10M
# без архивирования нормально загружает
tar cf - testfile.tmp | pigz > testfile.tar.gz
python3 ydsk.py --path_from=testfile.tar.gz --path_to=testfile.tar.gz --auth_appid=aaa --auth_appsecret=bbb --auth_apptoken=ccc
Файл ydsk.py: https://gist.github.com/saippuakauppias/0680b0bcedef5c6689459b055fe3b09a
Может быть что-то нужно дополнительно передавать в аргументах при загрузке больших файлов? Или, например, выгружать через open
?
ivknv commented
Для загрузки больших файлов нужно использовать увеличенный таймаут, возможно это связано с антивирусной проверкой на диске. Это старая проблема, тоже с этим сталкивался.