GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Document recommendations for retrying blob.upload_from_filename · Issue #352 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Document recommendations for retrying blob.upload_from_filename #352

Copy link
Copy link
Closed
#353
Closed
Document recommendations for retrying blob.upload_from_filename#352
#353
Copy link
Assignees
HemangChothani
Labels
api: storageIssues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@tschaub
tschaub
opened on Dec 23, 2020
Issue body actions

I'm seeing frequent 503 and 504 responses using the blob.upload_from_filename() method. An example trace looks like this:

503 POST https://storage.googleapis.com/upload/storage/v1/b/my-bucket/o?uploadType=multipart: {
  "error": {
    "code": 503,
    "message": "Backend Error",
    "errors": [
      {
        "message": "Backend Error",
        "domain": "global",
        "reason": "backendError"
      }
    ]
  }
}
: (u'Request failed with status code', 503, u'Expected one of', 200)' - Calling rollback() ...
Traceback (most recent call last):
  File "/my/app/module.py", line 112, in upload
    blob.upload_from_filename(file_path)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/storage/blob.py", line 2471, in upload_from_filename
    checksum=checksum,
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/storage/blob.py", line 2359, in upload_from_file
    _raise_from_invalid_response(exc)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/storage/blob.py", line 3886, in _raise_from_invalid_response
    raise exceptions.from_http_status(response.status_code, message, response=response)
ServiceUnavailable: 503 POST https://storage.googleapis.com/upload/storage/v1/b/my-bucket/o?uploadType=multipart: {
  "error": {
    "code": 503,
    "message": "Backend Error",
    "errors": [
      {
        "message": "Backend Error",
        "domain": "global",
        "reason": "backendError"
      }
    ]
  }
}
: (u'Request failed with status code', 503, u'Expected one of', 200)

It looks like this method calls blob.upload_from_file() with num_retries=None, so there is no retry strategy applied. I also see that the num_retries argument is documented as deprecated.

Does this library provide an alternative way to retry blob.upload_from_filename() or blob.upload_from_file()? I can wrap these calls in retry logic of my own, but I see that retries are enabled by default for other functions.

I'm using google-cloud-storage==1.34.0. I've already pulled in google-resumable-media==1.20.0 so I should be getting the recent resumable media retry fixes that came with #342.

Thanks for any tips on retrying uploads.

Activity

  1. product-auto-label
    added
    api: storageIssues related to the googleapis/python-storage API.
    on Dec 23, 2020
  2. HemangChothani commented on Dec 23, 2020

    @HemangChothani
    HemangChothani
    on Dec 23, 2020
    Contributor
    More actions

    @tschaub See the documentation of num_retries here

    By default, only uploads with if_metageneration_match set will be retried for the transient errors.For now num_retires parameter working fine and it will remove in the future so you can use that.
    The num_retries is not exposed for blob.upload_from_filename method so for now you can use blob.upload_from_file method.

    google-resumable-media==1.2.0 automatically pulled when you update your storage library to google-cloud-storage==1.35.0 and you will get the recent resumable media retry fix with it.

  3. HemangChothani
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Dec 23, 2020
  4. HemangChothani
    self-assigned this
    on Dec 23, 2020
  5. gcf-merge-on-green
    closed this as completedin #353on Feb 10, 2021
  6. gcf-merge-on-green
    added a commit that references this issue on Feb 10, 2021

    fix: expose num_retries parameter for blob upload methods (#353)

    This issue will close once commit fdabd6a is merged into the 'main' branch.
    fdabd6a
  7. cojenco
    added 2 commits that reference this issue on Oct 13, 2021

    fix: expose num_retries parameter for blob upload methods (googleapis…

    This issue will close once commit d44488e is merged into the 'main' branch.
    d44488e

    fix: expose num_retries parameter for blob upload methods (googleapis…

    This issue will close once commit c1aa23a is merged into the 'main' branch.
    c1aa23a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @HemangChothani
    HemangChothani

Labels

api: storageIssues related to the googleapis/python-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.