Uprava stahovani elevace, slouceni gps utils do jednoho filu, retryable, pridani social image k pilotovi a letu
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import asyncio
|
||||
|
||||
|
||||
def retryable(func):
|
||||
max_retries = 5
|
||||
|
||||
async def func_wrapper(*args, **kwargs):
|
||||
for i in range(1, max_retries):
|
||||
try:
|
||||
return await func(*args, **kwargs)
|
||||
except Exception as ex:
|
||||
if i > max_retries:
|
||||
raise ex
|
||||
sleep_time = i * 2
|
||||
print(
|
||||
"Error while getting the data from source:"
|
||||
" decorator is going to sleep for %s seconds"
|
||||
" and retry it again (%s/%s)" % (
|
||||
sleep_time, i, max_retries
|
||||
)
|
||||
)
|
||||
await asyncio.sleep(sleep_time)
|
||||
|
||||
return func_wrapper
|
||||
Reference in New Issue
Block a user