All Projects → seemethere → Retry.it

seemethere / Retry.it

Licence: mit
retry.it, a simple retry library

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Retry.it

Minimp3
Minimalistic MP3 decoder single header library
Stars: ✭ 898 (+1022.5%)
Mutual labels:  minimal
Minit
minimalist init implementation for containers
Stars: ✭ 45 (-43.75%)
Mutual labels:  minimal
Dropin Minimal Css
Drop-in switcher for previewing minimal CSS frameworks
Stars: ✭ 1,061 (+1226.25%)
Mutual labels:  minimal
Modalzinha Js
👨🏻‍💻 Very tiny modal in vanilla js.
Stars: ✭ 15 (-81.25%)
Mutual labels:  minimal
Minimal
Minimal Linux Live (MLL) is a tiny educational Linux distribution, which is designed to be built from scratch by using a collection of automated shell scripts. Minimal Linux Live offers a core environment with just the Linux kernel, GNU C library, and Busybox userland utilities.
Stars: ✭ 1,014 (+1167.5%)
Mutual labels:  minimal
Hellomello
Experiments with writing Android apps in Nim
Stars: ✭ 47 (-41.25%)
Mutual labels:  minimal
Calculator
Simple calculator built with React
Stars: ✭ 833 (+941.25%)
Mutual labels:  minimal
Minimal Feedback
🗳 minimal-feedback is a blazingly fast and highly customizable component to get user feedback.
Stars: ✭ 78 (-2.5%)
Mutual labels:  minimal
Minischeme
Cat's Eye Technologies' fork of the original public-domain Mini-Scheme implementation, miniscm.
Stars: ✭ 43 (-46.25%)
Mutual labels:  minimal
Lemon
🍋 Minimal and responsive CSS framework for fast building websites.
Stars: ✭ 51 (-36.25%)
Mutual labels:  minimal
Weatherapp
Cute weather app built in Electron
Stars: ✭ 32 (-60%)
Mutual labels:  minimal
Components
Example Components (Built with Tonic)
Stars: ✭ 42 (-47.5%)
Mutual labels:  minimal
Flowy
The minimal javascript library to create flowcharts ✨
Stars: ✭ 8,636 (+10695%)
Mutual labels:  minimal
Crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-72.5%)
Mutual labels:  minimal
Monoapp
choo architecture without a renderer
Stars: ✭ 52 (-35%)
Mutual labels:  minimal
Hugo Theme Terminal
A simple, retro theme for Hugo
Stars: ✭ 832 (+940%)
Mutual labels:  minimal
Fbbot
Minimal framework/SDK for facebook messenger bots. BYOS (Bring Your Own Server)
Stars: ✭ 46 (-42.5%)
Mutual labels:  minimal
Waffles
Bash Configuration Management
Stars: ✭ 79 (-1.25%)
Mutual labels:  minimal
Wallop
⛔️ currently unmaintained ⛔️ A minimal JS library for showing & hiding things
Stars: ✭ 1,125 (+1306.25%)
Mutual labels:  minimal
Derrick
🙌 Derrick is a clean minimal and fast theme for a personal blog.
Stars: ✭ 51 (-36.25%)
Mutual labels:  minimal

Travis PyPI Documentation Status Say Thanks!

🔄 retry.it, a simple retry library

Ever wanted to retry a function but didn't want to implement fancy logic to do it?

Well now you don't have to thanks to retry.it!

Thanks to this simple <100 line module you too can experience the wonders of retrying functions in all of their glory, without any of the fancy logic!

Have a function that only works some of the time? retry.it!

Have a function that needs to poll a website x times to check if something is down? retry.it!

Have a function that you just want to run over and over again? retry.it!

NOTE: Compatability for Windows is not yet available

Installation

pip install retry.it

Features

  • Functions can be retried based on:
    • Success criteria (like a status code not equaling 200)
    • Exceptions (like a function raising a requests.RequestException)
      • All accepted exceptions raise the original exception on failure as well!
  • Functions can fail based on:
    • Maximum number of retries exceeded
    • Maximum timeout achieved
  • Function retries can be spaced apart at a specific interval

Examples

Use it as a decorator!

Send a GET request to a URL until it returns a status code of 200! Rest a second between tries

import requests

from retry import retry

@retry(max_retries=-1, interval=1, success=lambda x: x.status_code == 200)
def poll_url(url, method='GET'):
    return requests.request(method, url)

Use it with a timeout!

Same function as above, timeout after 10 seconds!

import requests

from retry import retry

@retry(
    max_retries=-1, interval=1, success=lambda x: x.status_code == 200,
    timeout=10)
def poll_url(url, method='GET'):
    return requests.request(method, url)

Use it with Exceptions!

Same function as above, timeout after 10 seconds!

import requests

from retry import retry

@retry(
    exceptions=(requests.RequestException,), max_retries=-1, interval=1,
    success=lambda x: x.status_code == 200, timeout=10)
def poll_url(url, method='GET'):
    return requests.request(method, url)

Use it as a wrapper!

Send any type of request to a URL until it returns a status code set by the user!

import requests

from retry import retry

def poll_url(url, method='GET'):
    return requests.request(method, url)

def poll_url_with_retries(
        url, method='GET', max_retries=-1, interval=1, status_code=200):
    return retry(
        max_retries=max_retries,
        interval=interval,
        success=lambda x: x.status_code == status_code
        timeout=10)(poll_url)(url, method)

Contributing

  1. Fork the repo
  2. Commit changes to your Fork
  3. Submit those changes!

Why use retry.it

When looking for a library that does something similar to retry.it I could not find one that not only suited everything I needed but also was something I could understand and extend easily. Enter retry.it! retry.it aims to be simple and clocking in at <100 lines of real code it is simple!

Alternatives

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].