Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.1 Release #66

Merged
merged 3 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.9.0
current_version = 0.9.1
commit = True
tag = True

Expand Down
22 changes: 18 additions & 4 deletions frameioclient/uploader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os
import math
import requests
import threading
import concurrent.futures
import os

from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry


thread_local = threading.local()

Expand All @@ -11,6 +15,12 @@ def __init__(self, asset, file):
self.asset = asset
self.file = file
self.chunk_size = None
self.retry_strategy = Retry(
total=3,
backoff_factor=1,
status_forcelist=[400, 500, 503],
method_whitelist=["PUT"]
)

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

def _get_session(self):
if not hasattr(thread_local, "session"):
thread_local.session = requests.Session()
if not hasattr(thread_local, "session"):
adapter = HTTPAdapter(max_retries=self.retry_strategy)
http = requests.Session()
http.mount("https", adapter)

thread_local.session = http
return thread_local.session

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

if chunk_id+1 == chunks_total:
is_final_chunk = True

session = self._get_session()

chunk_data = self._smart_read_chunk(chunk_offset, is_final_chunk)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from setuptools.command.install import install

version='0.9.0'
version='0.9.1'

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