Skip to main content

Build Status About

A simple util library for creating applications which needs to keep running, despite abnormalities

Installing

pip install pyrobustness

Usage

Timeout example:

from robust.tools import timeout


@timeout(5)
def very_long_job():
    import time
    while True:
      print("Zzz")
      time.sleep(1)

very_long_job()

Retry example:

from robust.tools import retry

@retry(5)
def very_broken_method():
    print(".")
    raise RuntimeError("Something is broken...")

while True:
    very_broken_method()

Circuit Breaker example:

import time
from robust.tools import breaker

counter = 0

@breaker(limit=5, revive=5)
def very_broken_method():
    nonlocal counter
    if counter <= 5:
        counter += 1
    	raise RuntimeError("Something is broken...")
    else:
        print("We've made it!")


while True:
    try:
    	very_broken_method()
    except RuntimeError:
        pass
    except Exception:
        break

time.sleep(5)
very_broken_method()

Version History

  • 1.1:
    • Additional type for alarm - threading to support Windows OS, or certain cases when signal is not working as supposed
    • CircuitBreaker pattern, inspired by speech by Daniel Riti @Pycon 2016
  • 1.0: Initial version

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrobustness-1.1.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrobustness-1.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pyrobustness-1.1.2.tar.gz.

File metadata

  • Download URL: pyrobustness-1.1.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pyrobustness-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0aeed1e808aea7320cde4cb0191c8c17d94fecfa5f192f64cfa8a999bc397779
MD5 2487617c6d5a6f77ecc60b40c305b173
BLAKE2b-256 e0df5f80b9eea8360c3a37db211cf91ba154810339abc4adcc1bcb23dc3b3422

See more details on using hashes here.

File details

Details for the file pyrobustness-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyrobustness-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for pyrobustness-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce74daa3e528e65fe083170e3672f53482f9cfe5dabc41485eb1351382ac0e8e
MD5 ced517c899982454a7ce8386c8faec77
BLAKE2b-256 27899d487e513136bde56e70ab436a4edbc207a0b5d28340dd85cb96d328e152

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 files

1.1.1

2 files

1.1.0

1 file

1.0.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page