Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Safety belt for your Python distributed services.

Project description

https://img.shields.io/pypi/v/safepy.svg https://img.shields.io/:license-Apache_2_License-blue.svg https://img.shields.io/pypi/pyversions/safepy.svg https://api.shippable.com/projects/587b8d9379509c10004a444b/badge?branch=master https://api.shippable.com/projects/587b8d9379509c10004a444b/coverageBadge?branch=master

Safepy (rhymes with safety) is a latency and fault tolerance library for Python 3.5 (or greater) inspired by Hystrix, Cloud Design Patterns, AWS Architecture Blog and many others.

How to use the library

You can either use the mechanisms as decorators:

from safety import retry

class ProfileService(object):
    @retry(attempts=3, base_delay=1)
    async def get_profile(self, username):
        ...

Or to dynamically recreate protected methods:

from safety import retry

class ProfileService(object):
    def __init__(self):
        self.get_profile = retry(attempts=3, base_delay=1)(
            self.get_profile
        )

    async def get_profile(self, username):
        ...

Retry

from safepy import retry

class ServiceA(object):
    @retry(attempts=3, base_delay=1)
    async def call():
        ...

Notes

  • The default retry is an alias for retry_with_jitter_backoff, a retry mechanism which uses jitter backoff. For exponential backoff use retry_with_exponential_backoff.

Project details


Download files

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

Files for safepy, version 0.1.0a0
Filename, size File type Python version Upload date Hashes
Filename, size safepy-0.1.0a0-py3-none-any.whl (9.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size safepy-0.1.0a0.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page