b2blaze icon indicating copy to clipboard operation
b2blaze copied to clipboard

File upload fails with Connection Error

Open torbenal opened this issue 6 years ago • 1 comments

Uploading a file returns the following error: requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)) I've been debugging for a while and can't figure out whether it's a problem with the module or Backblaze's services.

torbenal avatar Feb 14 '19 18:02 torbenal

I figure it probably has to do with threading. See https://requests.readthedocs.io/en/master/user/advanced/#blocking-or-non-blocking:

Blocking Or Non-Blocking? With the default Transport Adapter in place, Requests does not provide any kind of non-blocking IO. The Response.content property will block until the entire response has been downloaded. If you require more granularity, the streaming features of the library (see Streaming Requests) allow you to retrieve smaller quantities of the response at a time. However, these calls will still block.

As soon as the request.post is called it blocks and times out.

def upload_large_file(...):
  # inside upload_large_file is the worker::
  def upload_part_worker(...):
     # which uses upload_part to do the work
     upload_part_response = self.connector.upload_part(...)
       # to serve it 
       def upload_part(...): 
          # upload_part uses a regular blocking requests.post  from inside the upload_part_worker. 
          return requests.post(upload_url, headers=headers, data=data) 
          # and hangs...

Hope this helps.

remcoboerma avatar Dec 13 '19 10:12 remcoboerma