error uploading file to google drive with python

Question:

I wrote a code to upload (create and update) a file to google drive,
in Windows 10 with python 3.9 it work, but in windows 2008 server with python 3.8 it give me an error.

just to remember 3.8 is the max version that supports windows 2008

if I try to list from gdrive it work, the problem is just to create or update the file.
just to remember 3.8 is the last python version that supports windows 2008.
I suspect its related with windows 2008 and ssl maybe!?!?

the error is this:

C:backupmgr>python drive.py
Traceback (most recent call last):
  File "drive.py", line 112, in <module>
    envia_zip('sexta.7z')
  File "drive.py", line 104, in envia_zip
    file = service.files().create(body=file_metadata, media_body=media).execute(
)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackagesgoogleapiclient_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackagesgoogleapiclienthttp.py", line 923, in execute
    resp, content = _retry_request(
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackagesgoogleapiclienthttp.py", line 222, in _retry_request
    raise exception
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackagesgoogleapiclienthttp.py", line 191, in _retry_request
    resp, content = http.request(uri, method, *args, **kwargs)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackagesgoogle_auth_httplib2.py", line 218, in request
    response, content = self.http.request(
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackageshttplib2__init__.py", line 1720, in request
    (response, content) = self._request(
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackageshttplib2__init__.py", line 1440, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, he
aders)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libsite-p
ackageshttplib2__init__.py", line 1363, in _conn_request
    conn.request(method, request_uri, body, headers)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libhttpc
lient.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libhttpc
lient.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libhttpc
lient.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libhttpc
lient.py", line 1046, in _send_output
    self.send(chunk)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libhttpc
lient.py", line 968, in send
    self.sock.sendall(data)
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libssl.py
", line 1204, in sendall
    v = self.send(byte_view[count:])
  File "C:UsersAdministradorAppDataLocalProgramsPythonPython38libssl.py
", line 1173, in send
    return self._sslobj.write(data)
socket.timeout: The write operation timed out

Asked By: flierd

||

Answers:

Well it works now, as @DaImTo poited to the issue #632 in the google api github, it is not a problem with the api. The problem is that the socket core module has low default timeout. The pc with windows server 2008 that I was using was very slow and was hiting this default timeout, so I just had rise the default timeout by inserting the code in the beginin of the script:

import socket
socket.setdefaulttimeout(600)
Answered By: flierd