cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error while uploading a zip file using Python script

Error while uploading a zip file using Python script

Apollonius
Explorer | Level 4
Go to solution

 I'm trying to write a Python script where there would be a list of "paths" to files and they would serially be uploaded to my Dropbox.

 

I thought of uploading a directory as a Zip archive if the list contains such an element. It's just a silly project but just for learning purposes. I'm using a shell script to Zip that archive that's called from the Python Script( I know I can do that using Python alone, but this just makes things more interesting!:grin:).

Here are the links to my code: Python scriptBash script

 

And I'm getting the following errors:

 

Traceback (most recent call last):
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, 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 972, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.6/ssl.py", line 941, 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 "/home/sakib/.local/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 367, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/sakib/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, 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 972, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.6/ssl.py", line 941, 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 "pyptupMultiple2.py", line 93, in <module>
backup()
File "pyptupMultiple2.py", line 43, in backup
mode=WriteMode('overwrite'))
File "/home/sakib/.local/lib/python3.6/site-packages/dropbox/base.py", line 2207, in files_upload
f,
File "/home/sakib/.local/lib/python3.6/site-packages/dropbox/dropbox.py", line 274, in request
timeout=timeout)
File "/home/sakib/.local/lib/python3.6/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
timeout=timeout)
File "/home/sakib/.local/lib/python3.6/site-packages/dropbox/dropbox.py", line 449, in request_json_string
timeout=timeout,
File "/home/sakib/.local/lib/python3.6/site-packages/requests/sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/sakib/.local/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/home/sakib/.local/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/home/sakib/.local/lib/python3.6/site-packages/requests/adapters.py", line 495, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out',)

The Zip file is just 93 MB and so doesn't exceed the 150 MB limit. So what should I do here?

 

I'm pretty much a noob programmer, and this is the first time I'm working with API, so any help is much much appreciated...

 

Best regards,

Sakib

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Thanks for the report! This appears to be an issue when using the Dropbox Python SDK with Python 3. We're looking into it.

 

As a workaround, please try setting an unlimited timeout when constructing your Dropbox client, like this:

dropbox.Dropbox(TOKEN, timeout=None)

Please let me know if that does or doesn't help.

View solution in original post

5 Replies 5

Greg-DB
Dropbox Staff
Go to solution

Thanks for the report! This appears to be an issue when using the Dropbox Python SDK with Python 3. We're looking into it.

 

As a workaround, please try setting an unlimited timeout when constructing your Dropbox client, like this:

dropbox.Dropbox(TOKEN, timeout=None)

Please let me know if that does or doesn't help.

Apollonius
Explorer | Level 4
Go to solution
Thanks, that did the trick...
But my script took 7 mins and 1.372 seconds. I guess that's to be expected given that the zip file is around 90 MB and I have a 250 kilobyte per sec broadband connection...
I'm curious though, is it because of Python 3 that larger files get "timed out" errors by default and I have to erase that limit by using timeout=None?

Greg-DB
Dropbox Staff
Go to solution
Great, thanks for confirming that.

Yes, between Python 2 and Python 3 there appears to be a change in behavior that results in this issue when using a non-None timeout. We're looking into it, but for now that workaround is required to avoid this issue.

Apollonius
Explorer | Level 4
Go to solution

Got it!:slight_smile:
If you don't mind, is there any way so that I can know that this issue has been fixed so that I can update my code?

Greg-DB
Dropbox Staff
Go to solution

I'll be sure to follow up here once I have an update on this issue.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Apollonius Explorer | Level 4
What do Dropbox user levels mean?