17th November 2021
Computer Science⚑
Programming⚑
(../computer_science/programming/python/asyncio.md)⚑
-
New: Limit concurrency.
Use (https://docs.python.org/3/library/asyncio-sync.html#semaphores).
sem = asyncio.Semaphore(10) async with sem: # work with shared resource
Other⚑
-
New: Retrying library for Python.
from tenacity import retry, stop_after_attempt, wait_exponential @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=0.1)) def somefunction(): raise Exception
The function will be retried a maximum of 3 times, waiting 0.1 s, 0.2 s and 0.4 s between each attempt respectively.