Skip to content

Commit 1cae062

Browse files
committed
Add rate limit handling
Remove version bump Fix version tag
1 parent f082a94 commit 1cae062

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

frameioclient/client.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from .upload import FrameioUploader
2+
from ratelimit import RateLimitException
3+
from backoff import on_exception, expo
24
import requests
35

46
class PaginatedResponse(object):
@@ -18,6 +20,7 @@ def __init__(self, token, host='https://api.frame.io'):
1820
self.token = token
1921
self.host = host
2022

23+
@on_exception(expo, RateLimitException, max_tries=10)
2124
def _api_call(self, method, endpoint, payload={}):
2225
url = '{}/v2{}'.format(self.host, endpoint)
2326

@@ -43,6 +46,10 @@ def _api_call(self, method, endpoint, payload={}):
4346
)
4447

4548
return r.json()
49+
50+
if r.status_code == "429":
51+
raise RateLimitException
52+
4653
return r.raise_for_status()
4754

4855
def get_me(self):

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
name='frameioclient',
88
python_requires='>=2.6, !=3.8.*, <4',
99
version='0.6.0',
10+
install_requires=[
11+
"requests",
12+
"ratelimit",
13+
"backoff",
14+
],
1015
description='Client library for the Frame.io API',
1116
long_description=long_description,
1217
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)