From 260db98e0c31fc4dc109e4743fa23f91d45d9a6b Mon Sep 17 00:00:00 2001 From: Ronnie V Date: Sun, 5 Nov 2023 22:24:13 +0800 Subject: [PATCH] feat(classes.py): add retry decorator for _request (#10) --- requirements.txt | 1 + src/pyplayht/classes.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 62bd824..1af9436 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ python-dotenv>=0.20.0 requests>=2.28.2 +retry2>=0.9.5 diff --git a/src/pyplayht/classes.py b/src/pyplayht/classes.py index 1a99058..f7edecd 100644 --- a/src/pyplayht/classes.py +++ b/src/pyplayht/classes.py @@ -3,6 +3,7 @@ from urllib.parse import urljoin, urlparse, urlunparse import requests +from retry import retry from pyplayht.types import VoiceType @@ -105,6 +106,7 @@ def download_file(self, uri: str) -> bytes: response = self._request("GET", new_url) return response.content + @retry(tries=3, delay=5, backoff=2) def _request( self, method: str,