Saravanan666/pypi-org huggingface dataset:
Package: retryCommand
Retry CommandIntroductionRetry Command is a Python library that allows you to retry executing a command multiple times until it succeeds or reaches the maximum number of retries. It provides options to customize the behavior of retries, such as setting a timeout for each execution and specifying the return codes that indicate success.InstallationTo use Retry Command, you need to have Python installed on your system. You can install the library using pip:pipinstallretryCommandUsageRetry Command can only be used as a standalone scriptStandalone ScriptTo use Retry Command as a standalone script, you can run the following command:do-retry[options]-c<command>Replace<command>with the command you want to execute. You can also specify various options to customize the behavior of retries. Use the-hor--helpoption to see the available options and their descriptions.OptionsRetry Command provides several options to customize the behavior of retries:-s, --no-stop-after-success: Do not stop retrying after the command succeeds.-p, --no-ignore-process-error: Do not stop retrying after encountering a process error.-m, --max-num-of-retry: Maximum number of retries. Set to -1 for unlimited retries.-i, --interval: Interval between retries in seconds.-t, --time-out: Timeout for each execution in seconds. Set to -1 for no timeout.-d, --cwd: Current working directory for the command.-n, --success-return-code: Return codes that indicate success. Multiple values can be specified.-q --quite: mute more output.--mute: mute all output.-l, --no-need-to-log: Does not output any records outside of stdou. It only works when mute is on.-c, --command: Command to execute.ExamplesHere are some examples of how to use Retry Command:Retry executing a command until it succeeds, ignoring process errors:do-retry-c<command>Retry executing a command with a maximum of 3 retries, an interval of 2 seconds, and a timeout of 5 seconds:do-retry-m3-i2-t5-c<command>LicenseRetry Command is licensed under the MulanPSL-2.0 License. See theLICENSEfile for more information.
Package: retry-deco
UsageRetry decorator#!/usr/bin/env python

from __future__ import print_function
import sys
from retry_decorator import retry


def throw_err(msg):
    print('hello', file=sys.stderr)
    raise Exception('throwing err for {}'.format(msg))


def callback(msg):
    print('callback called: {}'.format(msg), file=sys.stderr)


@retry(Exception, tries=3, timeout_secs=0.1)
def test_retry_via_decorator():
    throw_err('retry-via-deco')


def test_retry_via_instance():
    cbe = {
        Exception: lambda: callback('retry-via-instance')
    }
    retry(tries=3, callback_by_exception=cbe)(throw_err)('retry-via-instance')


if __name__ == '__main__':
    try:
        test_retry_via_decorator()
    except Exception as e:
        print('Received the last exception')

    try:
        test_retry_via_instance()
    except Exception as e:
        print('Received the last exception')CreditsThis project is a fork of upstreamhttps://github.com/pnpnpn/retry-decoratorContributeBest contribute to [upstream](https://github.com/pnpnpn/retry-decorator) project,
but it _might_ be abandoned. Also its defaults will be different from this project,
unless [PR21](https://github.com/pnpnpn/retry-decorator/pull/21) (which is the reason
for this fork) is accepted.So… it’s up to you which project you raise your PR against, but contributions are welcome.See also[PyRetry](https://github.com/Abeautifulsnow/PyRetry)[retry_module](https://github.com/adityaprakash-bobby/retry_module)[retry2](https://github.com/eSAMTrade/retry)
Package: retry-decorator
UsageRetry decorator#!/usr/bin/env python

from __future__ import print_function
from retry_decorator import *

@retry(Exception, tries = 3, timeout_secs = 0.1)
def test_retry():
    import sys
    print('hello', file = sys.stderr)
    raise Exception('Testing retry')

if __name__ == '__main__':
    try:
        test_retry()
    except Exception as e:
        print('Received the last exception')ContributeI would love for you to fork and send me pull request for this project. Please contribute.
Package: retryer
RetryrA Python decorator that allows you to retry a function, and customise the action if it runs into error.InstallationYou can install this package using pip:pipinstallretryer# Usagefromretryrimportretryer# Define your custom_action functiondefcustom_action(exception):print(f"Custom error handling: {exception}")# You can perform any action you want here@retryer(max_retries=5,retry_delay=2,on_error=custom_action)defyour_function():# Your code here# If this function raises an error, it will retry up to 5 times with a 2-second delay.if__name__=="__main__":your_function()Parametersmax_retries: The maximum number of times the function should be retried on error.retry_delay: The delay in seconds between retry attempts.on_error: A custom error handling function that will be executed when an error occurs.LicenseThis project is licensed under the MIT License - see the LICENSE file for details.
Package: retry-helper
Retry HelperHelper tool fro retrying code when soem exceptions occurUsageRetryManagerRetry manager is context manager for retrying block of code. In fact its double layer context manager in first context you will create context manager and use while retry object is true. And the run you code in context of retry.attempt.max_attempts - maximum count of attempts, default 1wait_seconds - How many second it should wait before next retry, default 0exceptions - exception class or tuple of exceptions classes which cause retry, if None all exceptions cause retry default Nonereset_func - function to be run before each retry (it is not call on first try)with RetryManager(max_attempts=20, wait_seconds=1, exceptions=(TypeError,KeyError)) as retry:
while retry:
    with retry.attempt:
        # code raising exception if fail
Package: retrying-async
info:Simple retrying for asyncioInstallationpipinstallretrying-async==1.1.0-ihttps://pypi.org/pypiUsageimportasynciofromretrying_asyncimportretrycounter=0@retry(attempts=3,delay=3)asyncdeffn():globalcountercounter+=1ifcounter==1:raiseRuntimeErrorasyncdefmain():awaitfn()loop=asyncio.get_event_loop()loop.run_until_complete(main())assertcounter==2loop.close()Python 3.5+ is required
Package: retry-iter
Retry Iter - The easy way to handle retries via iterationThis module provides to generator functions, that could be used to handle
retries via iteration. What could be easier then just iterate over attempts?Take a look at examples below:Synchronous retryfromretry_iterimportretry_iterstate=Falseforattemptinretry_iter(max_retries=5):ifdo_operation(params):state=Truebreakifnotstate:raiseException("Operation failed")Asynchronous retryfromretry_iterimporta_retry_iterstate=Falseasyncforattemptina_retry_iter(max_retries=5):ifawaitdo_operation(params):state=Truebreakifnotstate:raiseException("Operation failed")Yodoo Cockpit - Manage your odoo infrastructure via odooTake a look atYodoo Cockpitproject, and discover the easiest way to manage your odoo installation.
Just short notes aboutYodoo Cockpit:
- start new production-ready odoo instance in 1-2 minutes.
- add custom addons to your odoo instances in 5-10 minutes.
- out-of-the-box email configuration: just press button and add some records to your DNS, and get a working email
- make your odoo instance available to external world (internet) in 30 seconds (just add single record in your DNS)If you have any questions, then contact us atinfo@crnd.pro, so we could schedule online-demonstration.Level up your service qualityLevel up your service with ourHelpdesk/Service Desk/ITSMsolution.Just test it atyodoo.systems: choose template you like, and start working.Test all available features ofBureaucrat ITSMwiththis template.Bug trackerBugs are tracked onCR&D’s Helpdesk.
In case of trouble, please report there.MaintainerOur web site is:https://crnd.pro/This module is maintained by theCenter of Research & Developmentcompany.We can provide you further Odoo Support, Odoo implementation, Odoo customization, Odoo 3rd Party development and integration software, consulting services (more info available onour site).Our main goal is to provide the best quality product for you.For any questionscontact us.
Package: retrylib
Library to make code more robustRetry decorator parametersretry(attempts_number, delay=0, step=0, max_delay=-1, retry_on=Exception, logger=None)attempts_number: number of function calls (first call + retries). If attempts_number < 0 then retry infinitelydelay: delay before first retrystep: increment value of timeout on each retrymax_delay: maximum delay value (upper bound for delay)retry_on: exception that should be handled or function that checks
if retry should be executed (default: Exception)logger: logger to write warningsreturns the result of decorated functionRetry on specific exceptionfrom retrylib import retry

@retry(attempts_number=3, retry_on=(MyException,))
def function():
  raise MyException()Use custom functionfrom retrylib import retry

def is_my_exception(error):
  return isinstance(error, MyException)

@retry(attempts_number=3, retry_on=is_my_exception)
def function():
  raise MyException()Retry on network errorsYou can use following code to add retries for your custom network
function:import requests
from retrylib.network import retry

@retry()
def function():
 response = requests.get('http://localhost:5002')
 response.raise_for_status()
 return response

function()LoggingGlobal logger: you can pass specific logger to decoratorimport logging
import logging.config

from retrylib.network import retry

LOGGING = {
  'version': 1,
  'formatters': {
      'precise': {
          'datefmt': '%Y-%m-%d,%H:%M:%S',
          'format': '%(levelname)-7s %(asctime)15s '
                    '%(name)s:%(lineno)d %(message)s'
      }
  },
  'handlers': {
      'console': {
          'class': 'logging.StreamHandler',
          'formatter': 'precise',
          'stream': 'ext://sys.stderr'
      },
  },
  'root': {
      'level': 'INFO',
      'handlers': ['console']
  }
}

logging.config.dictConfig(LOGGING)

LOGGER = logging.getLogger(__name__)

@retry(logger=LOGGER)
def function():
 response = requests.get('http://localhost:5002')
 response.raise_for_status()
 return responseObject-specific logger: to use object-specific logger define method 'get_logger'from retrylib import retry

class MyClass(object):
 def __init__(self):
     self._logger = logging.getLogger(__name__)

 def get_logger(self):
     return self._logger

 @retry()
 def my_method(self):
     ...
     raise Exception

obj = MyClass()
obj.my_method()
# obj._logger will be used
Package: retry_on_exceptions
# retry\_on\_exceptions decoratorDecorator for retrying a function N times by catching one of the specified exceptions and then retrying.Specially useful for functions that throws errors sporadically, like ones that depends on external resources as web APIs, databases, etc.Usage:from retry import retry_on_exceptionscurrent_try = 0@retry_on_exceptions(types=[ZeroDivisionError, KeyError], tries=3)def test():global current_trycurrent_try += 1if current_try == 1:return 1 / 0elif current_try == 2:return dict()['key']else:return "Got it on last try!"if __name__ == "__main__":print test()The code above prints (if root logger is active and on debug level):- Retrying function test- Retrying function test- Last try... and I will raise up whatever exception is raised- Got it on last try!Optionally, you can also specify a delay (a float in seconds), making the current thread sleep between tries:@retry_on_exceptions(types=[urllib2.URLError], tries=3, delay=3.5)
Package: retryp
From theJargon File:The -P Convention

Turning a word into a question by appending the syllable ‘P’;
from the LISP convention of appending the letter ‘P’ to denote
a predicate (a boolean-valued function). The question should
expect a yes/no answer, though it needn't. (See T and NIL.)retrypis yet another retry decorator, with nothing particularly
special about it other than it being both well-featured and not
rewriting or hiding the calling signature of the wrapped method (allows
for accurate code introspection – a Big Deal for me).Thanks go to Graham Dumpleton and hiswraptpackage for that latter.ArgumentsbackoffDefault: 10A multiplicative factor applied to the delay, used to provide
increasing backoff as subsequent attempts continue to fail.countDefault: 10Number of times to retry the wapped item.  If set to “0”, will retry
1073741823 times because a) that’s a lot, b) give up already, and c)
nothing lasts forever.delayDefault: 10 (seconds)The base delay between retry attempts.expose_last_excDefault: FalseBy defaultretrypwill raiseretryp.FailedTooOftenif the
wrapped item continues to fail after the requested number of
attempts.  Ifexpose_last_excis set, then the exception raised
by the wrapped item will be raised if the last attempt results in an
exception.jitterDefault 0Extra random seconds will be added to each retry delay, ranging from
0 to the value ofjitter.log_faultsDefault: FalseLog every exception raised by the wrapped item using
logtool.log_fault.log_faults_levelDefault: logging.DEBUGLogging level at which exceptions will be logged bylogtool.log_fault()whenlog_faultsis set.nameDefault: NoneString to use in log messages to describe what is being retried.refuse_rc_fnDefault: NoneIf provided, the return of the wrapped item will be passed as the
only argument to this function.  Ifrefuse_rc_fn (rc)evaluates
to True, then no further retries will be made.refuse_exc_fnDefault: NoneIf provided, any exception raised by the wrapped item will be passed
as the only argument to this function.  Ifrefuse_exc_fn (e)evaluates to True, then the exception will be raised again and
retry attempts will cease.
Package: retry-pytest
importoperatorfromretry_pytest.retryimportRetrywithRetry()asr:r.check(operator.sub,4,2).equal(2)importoperatorfromretry_pytest.retryimportRetrywithRetry(ZeroDivisionError,title='custom allure step title for skip ZeroDivisionError',timeout=10,poll_frequency=2)asr:r.check(operator.truediv,4,0).equal(2)importoperatorfromretry_pytest.retryimportRetrywithRetry()asr:r.check(operator.sub,4,2).equal(1)r.on_timeout(print,'wtf')importoperatorfromretry_pytest.retryimportRetrywithRetry()asr:r.check(operator.sub,4,2).equal(2)r.check(operator.add,2,2).equal(4)fromretry_pytest.retryimportRetrydefget_result_as_list_of_dicts():return[{'key1':'data1','key2':'data2'}]withRetry()asr:r.check(get_result_as_list_of_dicts).get(0).get('key1').equal('data1')fromretry_pytest.retryimportRetrydefget_result_as_list():return[1,2,3]withRetry()asr:r.check(get_result_as_list).get(0).equal(1)fromretry_pytest.retryimportRetrydefget_result_as_dict():return{'key1':'data1','key2':'data2'}withRetry()asr:r.check(get_result_as_dict).get('key1').equal('data1')fromretry_pytest.retryimportRetrydefget_result_as_list_of_dicts():return[{'key1':'data1','key2':'data2'}]withRetry()asr:r.check(get_result_as_list_of_dicts).get(0).get('key1').equal('data1')r.check(get_result_as_list_of_dicts).get(0).get('key2').equal('data2')print(r.commands[-2].result)print(r.last_command.result)
Package: retry-redis
retry-redisRedis Clieht with customizable retrying capability.Why did I build this?There are Redis exceptions like below that can be handled by simply retrying it.This package is built in order to help people who need to solve same problem.redis.exceptions.ConnectionErrorredis.exceptions.ResponseErrorredis.exceptions.TimeoutErrorWho should use?Anybody who wants to have retry logic with Redis.How to Installpipinstallretry-redisHow To UseSimply import retry decorated Redis and Use it.importloggingfromretry_redisimportRedislogging.basicConfig(level=logging.DEBUG)r=Redis(port=6666)r.lpush('list:test',1)# This log will be printed.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 0.002(s), this was the 1st time calling it.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 2.005(s), this was the 2nd time calling it.# DEBUG:retry_redis.decorated_redis:Finished call to 'redis.client.Redis.lpush' after 6.009(s), this was the 3rd time calling it.Package Dependencyredistenacity
Package: retryrequests
retryrequestsSummaryInstallationUsageDependenciesSummaryA Python library that make HTTP requests with exponential back-off retry by usingrequestspackage.Installationpip install retryrequestsUsageretryrequestshas same interface withrequests:Sample Code:importjsonimportretryrequestsr=retryrequests.get("https://kctbh9vrtdwd.statuspage.io/api/v2/status.json")r.raise_for_status()print(json.dumps(r.json(),indent=4))Output:{"page":{"id":"kctbh9vrtdwd","name":"GitHub","url":"https://www.githubstatus.com","time_zone":"Etc/UTC","updated_at":"2019-03-30T07:11:24.851Z"},"status":{"indicator":"none","description":"All Systems Operational"}}DependenciesPython 3.6+requests
Package: retry-requests
Configures the passed-inrequests’Sessionto retry on failed requests due to connection errors, timeouts,
specific HTTP response codes (5XX by default) and 30X redirections
—anything that could fail.Python 3.6+.Basic usage:fromretry_requestsimportretrymy_session=retry()my_session.get("http://foo.bar")Thisgetwill retry three times in case of error waiting some time between retries.
Errors could be:Waiting for the server to start answering for 5 seconds.No access to the server or a dropped connection.An HTTP answer of 500, 502, or 504.You can change these defaults:fromretry_requestsimportretryfromrequestsimportSessionmy_session=retry(Session(),retries=5,backoff_factor=0.2)my_session.get('https://foo.bar')Check the functionretryto know more about this configuration.Note that you have aTSession, aSessionwith a default timeout,
andRSession, aSessionwith a timeout that alwaysraise_for_status(),
for your convenience.Heavily inspired fromPeterbe.com. Thank you!InstallingJustpip installretry-requests.TestingClone this project and then, at its root directory, runpython setup.py test.
Note that you need an active Internet connection to run the tests.
Package: retry-sh
Easy to use retry decorator.Step sideIt’s fork:https://github.com/invl/retryMy changes had started from version 0.9.3 (see ChangeLog)FeaturesNo external dependency (stdlib only).(Optionally) Preserve function signatures (pip install decorator).Original traceback, easy to debug.Installation$pipinstallretry-shAPIretry decoratorVarious retrying logic can be achieved by combination of arguments.Examplesfromretryimportretry@retry()defmake_trouble():'''Retry until succeed'''@retry(ZeroDivisionError,tries=3,delay=2)defmake_trouble():'''
    Retry on ZeroDivisionError,
    raise error after 3 attempts, sleep 2 seconds between attempts.
    '''@retry((ValueError,TypeError),delay=1,backoff=2)defmake_trouble():'''
    Retry on ValueError or TypeError,
    sleep 1, 2, 4, 8, ... seconds between attempts.
    '''@retry((ValueError,TypeError),delay=1,backoff=2,max_delay=4)defmake_trouble():'''
    Retry on ValueError or TypeError,
    sleep 1, 2, 4, 4, ... seconds between attempts.
    '''@retry(ValueError,delay=1,jitter=1)defmake_trouble():'''
    Retry on ValueError,
    sleep 1, 2, 3, 4, ... seconds between attempts.
    '''# If you enable logging, you can get warnings like 'ValueError, retrying in# 1 seconds'if__name__=='__main__':importlogginglogging.basicConfig()make_trouble()retry_callThis is very similar to the decorator, except that it takes a function and its arguments as parameters.
The use case behind it is to be able to dynamically adjust the retry arguments.importrequestsfromretry.apiimportretry_calldefmake_trouble(service,info=None):ifnotinfo:info=''r=requests.get(service+info)returnr.textdefwhat_is_my_ip(approach=None):ifapproach=="optimistic":tries=1elifapproach=="conservative":tries=3else:# skepticaltries=-1result=retry_call(make_trouble,fargs=["http://ipinfo.io/"],fkwargs={"info":"ip"},tries=tries)print(result)what_is_my_ip("conservative")
Package: retryz
VERSION: 0.1.9IntroductionFunction decorator that helps to retry the function under certain criteria.This package contains theretrydecorator and a bunch of configuration
parameters for this decorator.Tested on python 2.7 and python 3.4.For quick start, check the tutorial section of this page.
Check [test_retryz.py](test/test_retryz.py) for detail examples.Installationpip install retryzLicenseApache License version 2TutorialRetry ifValueErroris caught.@retry(on_error=ValueError)defmy_func():...Retry ifValueErrororTypeErroris caught.@retry(on_error=lambdae:isinstance(e,(ValueError,TypeError)))defmy_func():...Retry untilTypeErroris caught.@retry(on_error=lambdae:notisinstance(e,TypeError))defmy_func():...Retry untilTypeErrororAttributeErroris caught.@retry(on_error=lambdae:notisinstance(e,(TypeError,AttributeError)))defmy_func():...Whenon_erroris a callback,
it will retry untilon_errorreturnsFalse.  Note that callback
takes one parameter which is the error instance raised by the decorated
function.def_error_callback(self,ex):assert_that(ex,instance_of(TypeError))returnself.call_count!=4@retry(on_error=_error_callback)deferror_call_back(self):...Retry if returns certain value.@retry(on_return=True)defmy_func(self):...Retry if return value in the list.@retry(on_return=lambdax:xin(1,2,3,4,5))defmy_func(self):...Retry until certain value is returned.@retry(on_return=lambdax:x!=4)defmy_func(self):...Retry until any of the value is returned.@retry(on_return=lambdax:xnotin[3,4])defmy_func(self):...Whenon_returnis a callback,
it will retry untilon_returnreturnsFalse.  Note that callback
takes one parameter which is the return value of the decorated function.def_return_callback(ret):return4+ret<7@retry(on_return=_return_callback)defmy_func(self):...Retry until timeout (in seconds)@retry(timeout=0.1)defmy_func():...Retry maximum X times.@retry(limit=3)defmy_func():...# or you could specify a callback@retry(limit=lambda:4)defmy_func_x():...Wait X seconds between each retry.@retry(wait=0.1,timeout=0.3)defmy_func():...Whenwaitis a callback, it will wait for the amount of
seconds returned by the callback.
The callback takes one parameter which is the current count of retry.def_wait_callback(self,tried):return2**tried@retry(wait=_wait_callback,timeout=0.1)defmy_func():...on_retrycould be used to specify a callback.  This callback
is a function with no parameter.  It will be invoked before each
retry.  Here is a typical usage.defdo_login():# login if not...@retry(on_retry=do_login,limit=2)defrequests(resource_id):...retrycould also be called in a functional style.
Note that the return value is a function.  If you want to call
it, you need to add an extra().deffoo():...retry(foo,limit=3,timeout=5)()To file issue, please visit:https://github.com/jealous/retryzContact author:Cedric Zhuang <jealous@163.com>