All Projects → nerandell → async_retrial

nerandell / async_retrial

Licence: other
Python package for retrial of asyncio based coroutines

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to async retrial

Vibe Core
Repository for the next generation of vibe.d's core package.
Stars: ✭ 56 (+300%)
Mutual labels:  asynchronous, asyncio
Tornado Sqlalchemy
SQLAlchemy support for Tornado
Stars: ✭ 112 (+700%)
Mutual labels:  asynchronous, asyncio
Peony Twitter
An asynchronous Twitter API client for Python 3.5+
Stars: ✭ 62 (+342.86%)
Mutual labels:  asynchronous, asyncio
socketwrapper
Async/Sync networking library including UDP, TCP and TLS/TCP socket classes written in C++ 17.
Stars: ✭ 33 (+135.71%)
Mutual labels:  asynchronous, asyncio
Minotaur
A pythonic, asynchronous, inotify interface
Stars: ✭ 163 (+1064.29%)
Mutual labels:  asynchronous, asyncio
Halive
A fast http and https prober, to check which URLs are alive
Stars: ✭ 47 (+235.71%)
Mutual labels:  asynchronous, asyncio
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (+700%)
Mutual labels:  asynchronous, asyncio
Tornado Celery
Non-blocking Celery client for Tornado
Stars: ✭ 561 (+3907.14%)
Mutual labels:  asynchronous, asyncio
Kubernetes asyncio
Python asynchronous client library for Kubernetes http://kubernetes.io/
Stars: ✭ 147 (+950%)
Mutual labels:  asynchronous, asyncio
Purerpc
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio
Stars: ✭ 125 (+792.86%)
Mutual labels:  asynchronous, asyncio
Chili
Chili: HTTP Served Hot
Stars: ✭ 7 (-50%)
Mutual labels:  asynchronous, asyncio
Aiosmtplib
asyncio smtplib implementation
Stars: ✭ 200 (+1328.57%)
Mutual labels:  asynchronous, asyncio
Async Reduce
Reducer for similar simultaneously coroutines
Stars: ✭ 17 (+21.43%)
Mutual labels:  asynchronous, asyncio
Beanie
Micro ODM for MongoDB
Stars: ✭ 56 (+300%)
Mutual labels:  asynchronous, asyncio
Yappi
Yet Another Python Profiler, but this time thread&coroutine&greenlet aware.
Stars: ✭ 595 (+4150%)
Mutual labels:  asynchronous, asyncio
Backoff
Python library providing function decorators for configurable backoff and retry
Stars: ✭ 1,670 (+11828.57%)
Mutual labels:  asynchronous, asyncio
Aiotutorial
code snippets for asyncio tutorial
Stars: ✭ 257 (+1735.71%)
Mutual labels:  asynchronous, asyncio
Bocadillo
(UNMAINTAINED) Fast, scalable and real-time capable web APIs for everyone
Stars: ✭ 401 (+2764.29%)
Mutual labels:  asynchronous, asyncio
Edgedb Python
EdgeDB Python Driver
Stars: ✭ 113 (+707.14%)
Mutual labels:  asynchronous, asyncio
Paco
Small utility library for coroutine-driven asynchronous generic programming in Python 3.4+
Stars: ✭ 198 (+1314.29%)
Mutual labels:  asynchronous, asyncio

Retrial library for asyncio coroutines

https://travis-ci.org/nerandell/async_retrial.svg?branch=master

Easy to use retry library based on asyncio

Requirements

Installation

To install via pip

$ pip install async_retrial

To install from source

$ git clone https://github.com/nerandell/async_retrial
$ cd async_retrial
$ python setup.py install

Examples

You can either use RetryHandler or retry decorator

retry decorator

def retry(should_retry_for_result=_default_retry_for_result,
          should_retry_for_exception=_default_retry_for_exception,
          multiplier=2, timeout=None, max_attempts=None, strategy=None):
            """
    :param should_retry_for_result: A function that is called with argument as result to allow retrial for specific
                                    set of results. Must return a boolean value
    :param should_retry_for_exception: A function that is called if the function to be retried threw an exception
                                       allow retrial for specific set of exceptions. Must return a boolean value
    :param multiplier: Must be an integer value, If defined, the retrial would be exponential with this behind the
                       multiplier
    :param timeout: If defined, the function will be retried if no result was returned in this time.
    :param max_attempts: Max number of attempts to retry
    :param strategy: Must be a list of integers. If defined, retrial would follow this strategy. For ex. if strategy
                     is [1,3,5,8,11], function would be retried at 1, 3, 5, 8, 11, 11, 11, ... seconds
    :return:
    """

To use the decorator:

from retrial.retrial import retry

Using different settings:

@retry()
def my_function(*args, **kwargs):
    '''Retry till successful. Default multiplier is 2'''

@retry(multiplier=3)
def my_function(*args, **kwargs):
    '''Retry at 0, 3, 9, 27, 81 ... seconds until successful'''

@retry(strategy=[1, 1, 2, 3, 5, 8, 13])
def my_function(*args, **kwargs):
    '''Retry at 1, 1, 2, 3, 5, 8, 13, 13, 13 ... seconds until successful'''

@retry(max_attempts=3)
def my_function(*args, **kwargs):
    '''Retry for a maximum of 3 times'''

@retry(should_retry_for_result=lambda x: x < 0)
def my_function(*args, **kwargs):
    '''Retry if result is negative value'''

@retry(should_retry_for_exception=lambda x: isinstance(x, KeyError))
def my_function(*args, **kwargs):
    '''Retry if exception was of type KeyError'''

License

async_retrial is offered under the MIT license.

Source code

The latest developer version is available in a github repository: https://github.com/nerandell/async_retrial

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].