googleapis / googleapis/google-cloud-python

`transfer_manager`: `upload_many` and `upload_many_from_filenames` can hang indefinitely even with deadline

Đang mở
#17,959 0 bình luận 0 reaction 1 người được giao Được @rajeevpodar nhận Xem trên GitHub
api: storage priority: p2 type: bug
Ngôn ngữ chính
Python
Star
5.4k
Fork
1.8k
Merge trung bình
3 ngày 4 giờ
Pull request đã merge (30 ngày)
122

Mô tả

### Determine this is the right repository

- [x] I determined this is the correct repository in which to report this bug.

### Summary of the issue

**Context**
The docs for `transfer_manager.upload_many` and `transfer_manager.upload_many_from_filenames` say a deadline argument can be passed, which is supposed to kill the workers and raise a TimeoutError, but this doesn't seem to happen. Instead, we're seeing that it can actually hang indefinitely.

**Expected Behavior:**
A timeout error is raised after the deadline has passed.

**Actual Behavior:**
The method hangs indefinitely.

### API client name and version

google-cloud-storage v3.13.0

### Reproduction steps: code

This repro uses a patch to simulate a stuck upload. In reality, we see stuck uploads on the GCP server-side, but it's non-deterministic.

```python
import io, time
from unittest.mock import patch
from google.cloud.storage import Blob, transfer_manager

with patch.object(Blob, "_prep_and_do_upload", side_effect=lambda *a, **k: time.sleep(10)): # Simulate a stuck upload
start = time.monotonic()
transfer_manager.upload_many(
[(io.BytesIO(), Blob("x", bucket=None))],
worker_type=transfer_manager.THREAD,
deadline=.1,
)
print(f"Upload succeded in {time.monotonic() - start:.3f}s. A TimeoutError was expected.")
```

### Reproduction steps: actual results

```
❯ uv run repro.py
Upload succeded in 10.001s. A TimeoutError was expected.
```

### OS & version + platform

Ubuntu 26.04 LTS

### Python environment

Python 3.14.4

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

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

Đánh giá

Issue này chưa được đánh giá.

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.