Skip to content

Commit 0710e4e

Browse files
authored
Merge pull request #66 from Frameio/develop
0.9.1 Release
2 parents 70aa926 + c4e1fef commit 0710e4e

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.9.0
2+
current_version = 0.9.1
33
commit = True
44
tag = True
55

frameioclient/uploader.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import os
12
import math
23
import requests
34
import threading
45
import concurrent.futures
5-
import os
6+
7+
from requests.adapters import HTTPAdapter
8+
from requests.packages.urllib3.util.retry import Retry
9+
610

711
thread_local = threading.local()
812

@@ -11,6 +15,12 @@ def __init__(self, asset, file):
1115
self.asset = asset
1216
self.file = file
1317
self.chunk_size = None
18+
self.retry_strategy = Retry(
19+
total=3,
20+
backoff_factor=1,
21+
status_forcelist=[400, 500, 503],
22+
method_whitelist=["PUT"]
23+
)
1424

1525
def _calculate_chunks(self, total_size, chunk_count):
1626
self.chunk_size = int(math.ceil(total_size / chunk_count))
@@ -24,8 +34,12 @@ def _calculate_chunks(self, total_size, chunk_count):
2434
return chunk_offsets
2535

2636
def _get_session(self):
27-
if not hasattr(thread_local, "session"):
28-
thread_local.session = requests.Session()
37+
if not hasattr(thread_local, "session"):
38+
adapter = HTTPAdapter(max_retries=self.retry_strategy)
39+
http = requests.Session()
40+
http.mount("https", adapter)
41+
42+
thread_local.session = http
2943
return thread_local.session
3044

3145
def _smart_read_chunk(self, chunk_offset, is_final_chunk):
@@ -47,7 +61,7 @@ def _upload_chunk(self, task):
4761

4862
if chunk_id+1 == chunks_total:
4963
is_final_chunk = True
50-
64+
5165
session = self._get_session()
5266

5367
chunk_data = self._smart_read_chunk(chunk_offset, is_final_chunk)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from setuptools.command.install import install
66

7-
version='0.9.0'
7+
version='0.9.1'
88

99
with open("README.md", "r") as f:
1010
long_description = f.read()

0 commit comments

Comments
 (0)