Skip to content

Storage: Batch._do_request does not accept timeout kwarg #9951

@kgriffs

Description

@kgriffs

Environment details

Arch Linux (Docker; tag 20191205; https://hub.docker.com/_/archlinux)
PyPy3 7.2
google-cloud-storage-1.23.0

Steps to reproduce

  1. Use the batch() context manager to create a batch of blob deletes
  2. Execute the batch

Code example

def delete_all_by_prefix(self, prefix):
    blobs_to_delete = [blob for blob in self._bucket.list_blobs(prefix=prefix)]
    if not blobs_to_delete:
        return

    batch_size = 500
    for i in range(0, len(blobs_to_delete), batch_size):
        batch = blobs_to_delete[i:(i + batch_size)]

        with self._client.batch():
            for b in batch:
                b.delete()

Stack trace

Traceback (most recent call last):

  ...

  File "/opt/pypy3/site-packages/google/cloud/storage/blob.py", line 554, in delete
    self.name, client=client, generation=self.generation
  File "/opt/pypy3/site-packages/google/cloud/storage/bucket.py", line 1100, in delete_blob
    _target_object=None,
  File "/opt/pypy3/site-packages/google/cloud/_http.py", line 417, in api_request
    timeout=timeout,
  File "/opt/pypy3/site-packages/google/cloud/_http.py", line 275, in _make_request
    method, url, headers, data, target_object, timeout=timeout
    TypeError: _do_request() got an unexpected keyword argument 'timeout'

Other info

I was able to fix the issue by monkey-patching google.cloud.storage.batch.Batch._do_request.

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.type: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions