Azure / Azure/azure-storage-python

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

Đang mở
#650 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
343
Fork
243
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### 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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với delete_blobs trong azure/storage/blob/_container_client.py và theo dõi _batch_send trong azure/storage/blob/_shared/base_client.py đến azure/core/pipeline/_base.py, nơi traceback đi đến _prepare_multipart_mixed_request. Tái hiện việc xóa theo lô đã được báo cáo với azure-storage-blob 12.1.0 và xác minh rằng việc xóa nhiều blob không còn gây ra lỗi NoneType on_request.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
azure, python
Lĩnh vực
backend, cloud
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.