sibblegp / b2blaze

b2blaze
MIT License
607 stars 32 forks source link

File upload fails with Connection Error #30

Open torbenal opened 5 years ago

torbenal commented 5 years ago

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.

remcoboerma commented 4 years ago

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.