Skip to content

Commit

Permalink
Merge branch 'fix/pr' into kjr-development
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-silva-funttastic committed Sep 14, 2023
2 parents 4e1b93e + 8378155 commit b370f16
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def convert_market_name_to_hb_trading_pair(market_name: str) -> str:


def automatic_retry_with_timeout(retries=0, delay=0, timeout=None):
def decorator(func):
def decorator(function):
async def wrapper(*args, **kwargs):
errors = []

for i in range(retries + 1):
try:
result = await asyncio.wait_for(func(*args, **kwargs), timeout=timeout)
result = await asyncio.wait_for(function(*args, **kwargs), timeout=timeout)

return result
except Exception as e:
Expand All @@ -55,7 +55,11 @@ async def wrapper(*args, **kwargs):
error_message = f"Function failed after {retries} attempts. Here are the errors:\n" + "\n".join(errors)

raise Exception(error_message)

wrapper.original = function

return wrapper

return decorator


Expand Down
Loading

0 comments on commit b370f16

Please sign in to comment.