GithubHelp home page GithubHelp logo

pnpnpn / retry-decorator Goto Github PK

View Code? Open in Web Editor NEW
27.0 5.0 12.0 30 KB

Decorator for retrying when exceptions occur

License: MIT License

Python 96.50% Makefile 3.50%
python decorators retry exception-handling retry-library retrying retryer python-decorators

retry-decorator's Introduction

https://travis-ci.org/pnpnpn/retry-decorator.svg?branch=master

Usage

Retry 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')

Contribute

I would love for you to fork and send me pull request for this project. Please contribute.

retry-decorator's People

Contributors

fionn avatar jheld avatar pgajdos avatar pnpnpn avatar rjschwei avatar ruuda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

retry-decorator's Issues

Please add per-file licenses

The Chromium project (www.chromium.org) pulls in retry-decorator indirectly through the catapult (https://github.com/catapult-project/catapult/) and gsutil (https://github.com/GoogleCloudPlatform/gsutil) source repositories. In order for Chromium to be pulled into various Linux source distributions there's a requirement that all of the third party files pass the Linux licensecheck utility. Currently there are many files in the retry-decorator repository missing per-file licenses. From a current run of licensecheck, they are:

$ licensecheck -r . | grep "No copyright"
./setup.py: *No copyright* UNKNOWN
./retry_decorator/__init__.py: *No copyright* UNKNOWN
./retry_decorator/retry_decorator.py: *No copyright* UNKNOWN

We'd like to ask that per-file licenses be added to these files to make it easier to integrate retry-decorator not only into Chromium, but also Linux distributions in general. Thanks.

universal wheel

Hi!

Could you add a setup.cfg and enable the bdist universal option?

[bdist_wheel]
universal = 1

It would make installing the library via py2 and py3 easier.

And then upload this wheel to PyPI as a new version?

execute some code before retrying

Is it possible to execute some code before retrying?

For example:

try:		
	return function(base_db, sql_string, sql_vars, debug_sql)
except (AttributeError, MySQLdb.OperationalError):
	base_db.__init__()
	return self.retry_db_errors(function(base_db, sql_string, sql_vars, debug_sql))

timeout_secs is confusing

that parameter name should be replaced with "wait_secs" or "interval_secs" or something - it doesn't look like it's a timeout at all, but the interval between retries from what I can see.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.