Azure / Azure/azure-storage-python

Blob batch delete (container_client.delete_blobs) errors with: 'AttributeError: 'NoneType' object has no attribute 'on_request''

未关闭
#650 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
343
派生
243
PR 合并指标
30 天内没有已合并 PR

描述

### Which service(blob, file, queue) does this issue concern?
Blob

### Which version of the SDK was used? Please provide the output of `pip freeze`.
rio@rio-t460p:~$ pip3 freeze | grep az
azure-core==1.2.0
azure-identity==1.2.0
azure-storage-blob==12.1.0

### What problem was encountered?
```
def run_delete_blobs():
blob_service_client = BlobServiceClient(account_url=STORAGE_URL, credential=STORAGE_SAS)
container_client = blob_service_client.get_container_client(STORAGE_CONTAINER)
blob_list = [blob.name for blob in list(container_client.list_blobs())]
container_client.delete_blobs(*blob_list)

run_delete_blobs()
```
Results in error
```
Traceback (most recent call last):
File "blob_cleanup.py", line 108, in
run_delete_blobs()
File "blob_cleanup.py", line 106, in run_delete_blobs
container_client.delete_blobs(*blob_list)
File "/home/rio/.local/lib/python3.7/site-packages/azure/core/tracing/decorator.py", line 71, in wrapper_use_tracer
return func(*args, **kwargs)
File "/home/rio/.local/lib/python3.7/site-packages/azure/storage/blob/_container_client.py", line 1094, in delete_blobs
return self._batch_send(*reqs, **options)
File "/home/rio/.local/lib/python3.7/site-packages/azure/storage/blob/_shared/base_client.py", line 265, in _batch_send
request, **kwargs
File "/home/rio/.local/lib/python3.7/site-packages/azure/core/pipeline/_base.py", line 197, in run
self._prepare_multipart_mixed_request(request)
File "/home/rio/.local/lib/python3.7/site-packages/azure/core/pipeline/_base.py", line 185, in _prepare_multipart_mixed_request
_ for _ in executor.map(prepare_requests, requests)
File "/home/rio/.local/lib/python3.7/site-packages/azure/core/pipeline/_base.py", line 185, in
_ for _ in executor.map(prepare_requests, requests)
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator
yield fs.pop().result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/usr/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/rio/.local/lib/python3.7/site-packages/azure/core/pipeline/_base.py", line 180, in prepare_requests
_await_result(policy.on_request, pipeline_request)
AttributeError: 'NoneType' object has no attribute 'on_request'
```

### Have you found a mitigation/solution?
Work around is to just use the single file container_client.delete_blob within a for loop but it's fairly slow so not ideal on large containers.

贡献指南

打开贡献指南

调研方向

从 azure/storage/blob/_container_client.py 中的 delete_blobs 开始,跟踪 azure/storage/blob/_shared/base_client.py 中的 _batch_send 进入 azure/core/pipeline/_base.py,此处 traceback 会到达 _prepare_multipart_mixed_request。使用 azure-storage-blob 12.1.0 重现报告的批量删除,并验证删除多个 blob 不再引发 NoneType on_request 错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
azure, python
领域
backend, cloud
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。