Skip to content

Commit

Permalink
Supported method_whitelist and allowed_methods
Browse files Browse the repository at this point in the history
  • Loading branch information
adw0rd committed May 10, 2023
1 parent c263ab2 commit 1260fb9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
20 changes: 14 additions & 6 deletions instagrapi/mixins/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,20 @@ class PrivateRequestMixin:
def __init__(self, *args, **kwargs):
# setup request session with retries
session = requests.Session()
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=["GET", "POST"],
backoff_factor=2,
)
try:
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=["GET", "POST"],
backoff_factor=2,
)
except TypeError:
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["GET", "POST"],
backoff_factor=2,
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("https://", adapter)
session.mount("http://", adapter)
Expand Down
20 changes: 14 additions & 6 deletions instagrapi/mixins/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ class PublicRequestMixin:
def __init__(self, *args, **kwargs):
# setup request session with retries
session = requests.Session()
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=["GET", "POST"],
backoff_factor=2,
)
try:
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
method_whitelist=["GET", "POST"],
backoff_factor=2,
)
except TypeError:
retry_strategy = Retry(
total=3,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["GET", "POST"],
backoff_factor=2,
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("https://", adapter)
session.mount("http://", adapter)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

setup(
name="instagrapi",
version="1.17.7",
version="1.17.8",
author="Mikhail Andreev",
author_email="[email protected]",
license="MIT",
Expand Down

0 comments on commit 1260fb9

Please sign in to comment.