Skip to content

Commit 98a9a92

Browse files
committed
Fix the timeout error while uploading large files
1 parent b08d51c commit 98a9a92

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

solvebio/resource/object.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -951,18 +951,18 @@ def _upload_single_part(
951951

952952
# Calculate timeout based on part size
953953
part_size_mb = len(chunk_data) / (1024 * 1024)
954-
# Timeout scaling for large parts (5MB to 1GB+)
955-
# Formula: 3min base + 10s per MB
956-
base_timeout = 180 # 3 minutes base
957-
scaling_factor = 10 # 10 seconds per 1MB
958-
read_timeout = base_timeout + part_size_mb * scaling_factor
959-
connect_timeout = 30
954+
# Timeout scaling for large parts
955+
# Formula: 20min base + 30s per MB to handle very large parts
956+
# This ensures adequate timeout even with slow connections
957+
base_timeout = 1200 # 20 minutes base
958+
scaling_factor = 30 # 30 seconds per 1MB
959+
total_timeout = base_timeout + part_size_mb * scaling_factor
960960

961961
upload_resp = session.put(
962962
upload_url,
963963
data=chunk_data,
964964
headers=headers,
965-
timeout=(connect_timeout, read_timeout),
965+
timeout=total_timeout,
966966
)
967967

968968
if upload_resp.status_code == 200:

0 commit comments

Comments
 (0)