Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python retry libraries run a failed operation again after a delay until it succeeds or reaches a stop condition. A retry policy pairs conditions such as an exception type, a returned value, or an attempt limit with a wait between attempts. These libraries let apps and AI agents recover from network errors and brief outages in the services they call.
Popularity
Tenacity has the most monthly downloads in this comparison, at 429.7M.
@retrying.retry(
stop_max_attempt_number=CONF.agent.neutron_agent_max_attempts,
retry_on_exception=lambda e: isinstance(e, exception.NetworkError),
wait_fixed=CONF.agent.neutron_agent_status_retry_interval * 1000
)
def wait_for_port_status(client, port_id, status):
"""Wait for port status to be the desired status
:param client: A Neutron client object.
:param port_id: Neutron port_id
:param status: Port's target status, can be ACTIVE, DOWN ... etc.
:returns: boolean indicates that the port status matches the
required value passed by param status.
:raises: InvalidParameterValue if the port does not exist.
:raises: exception.NetworkError if port status didn't match
the required status after max retry attempts.
"""
LOG.debug('Validating Port %(port_id)s status is %(status)s',
{'port_id': port_id, 'status': status})
port = _get_port_by_uuid(client, port_id)
LOG.debug('Port %(port_id)s status is: %(status)s',
{'port_id': port_id, 'status': port.status})
if port.status == status:
return True
raise exception.NetworkError(
'Port %(port_id)s failed to reach status %(status)s' % {
'port_id': port_id, 'status': status})
stamina
Wraps Tenacity with bounded retry defaults, jitter, and instrumentation.
Downloads / mo
5.8M
Stars
1.5K
Last release
26.2.0
License
MIT
Strengths
Bounds retries by default.Configure attempt and total-time limits alongside exponential backoff and jitter.
Supports asyncio and Trio.Use the same retry functions with synchronous and asynchronous operations.
Limitations
Generator retries restart from beginning.Make repeated yielded work safe before retrying a generator.
Custom delays override backoff settings.An on-hook delay replaces the normal exponential backoff calculation.
@stamina.retry(on=Exception, attempts=3)
def list_remote_files_fsspec(
url: str, settings: Settings, cache_expiry: CacheExpiry = CacheExpiry.FILEINDEX
) -> list[str]:
"""Create a listing of all files of a given path on the server.
The default ttl with ``CacheExpiry.FILEINDEX`` is "5 minutes".
Args:
url: The URL to list files from.
settings: The settings to use for the listing.
cache_expiry: The cache expiration time.
Returns:
A list of all files on the server
"""
use_cache = not (settings.cache_disable or cache_expiry is CacheExpiry.NO_CACHE)
fs = HTTPFileSystem(
use_listings_cache=use_cache,
listings_expiry_time=not settings.cache_disable and cache_expiry.value,
listings_cache_location=settings.cache_dir,
client_kwargs=settings.fsspec_client_kwargs,
use_certifi=settings.use_certifi,
)
return fs.find(url)
@retry(HierarchyEmptyError, tries=3, delay=1)
def _do_dump_hierarchy(self, compressed=False, max_depth=None, root_in_active: Optional[bool] = None) -> str:
if max_depth is None:
max_depth = 50
if root_in_active is None:
content = self.jsonrpc.dumpWindowHierarchy(compressed, max_depth)
else:
content = self.jsonrpc.dumpWindowHierarchy(compressed, max_depth, root_in_active)
if content == "":
raise HierarchyEmptyError("dump hierarchy is empty")
# '<?xml version=\'1.0\' encoding=\'UTF-8\' standalone=\'yes\' ?>\r\n<hierarchy rotation="0" />' if '<hierarchy rotation="0" />' in content:
logger.debug("dump empty, call clear_traversed_text and retry")
# self.clear_traversed_text() raise HierarchyEmptyError("dump hierarchy is empty with no children")
return content
FAQ
Tenacity suits code that combines retry conditions or retries individual code blocks. stamina suits services that want bounded retries with jitter by default. backoff suits existing code built on its decorators, although its repository is archived.
Tenacity is a retry library with configurable decorators and code-block retry loops. By default it retries exceptions forever without waiting. A stop policy bounds the number of attempts.
Tenacity and backoff both retry asyncio coroutines. stamina supports asyncio and Trio with the same API.
stamina wraps Tenacity with bounded retry defaults, jitter, and instrumentation.
No. A retried generator restarts from the beginning.
For coding agents
Found your retry library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.