Skip to main content

redis-py that handles errors better.

Project description

This module wraps the execute_command method of the Redis class, allowing any retry passed to be used. It also introduces a new Backoff, LimitedTimeBackoff, allowing one to set a timeout before which the BackoffTimeoutExceeded is raised.

The purpose of the module is to provide an alternative to the official redis app, as we await an update to hanlding timeout errors.

Usage

Provide a retry to the Redis class which shall be used later.

Examples

import redis
import socket
import redis_exec_retry

max_seconds = 2
backoff_instance = redis.backoff.ExponentialBackoff()
retry = redis.retry.Retry(
    backoff=redis_exec_retry.LimitedTimeBackOff(max_seconds, backoff_instance=backoff_instance),
    retries=-1,
    supported_errors=(
        redis.exceptions.BusyLoadingError,
        redis.exceptions.ConnectionError,
        redis.exceptions.TimeoutError,
        socket.timeout,
    ),
)
r = redis_exec_retry.Redis(port=1000, retry=retry)
print(r.keys("*"))  # will run for 2 seconds before raising redis_exec_retry.BackoffTimeoutExceeded

Project details


Download files

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

Source Distribution

redis_exec_retry-0.0.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

redis_exec_retry-0.0.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file redis_exec_retry-0.0.2.tar.gz.

File metadata

  • Download URL: redis_exec_retry-0.0.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for redis_exec_retry-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4734d6e4802a4ca6c781984a114c24e4450815c99a4fde5801457318ca6a3de9
MD5 155b03c5e0042642775da0caaeafc32f
BLAKE2b-256 e439197f05008b20497c5a5099e50d2aac79cd623b65d27a96d67d2700821188

See more details on using hashes here.

File details

Details for the file redis_exec_retry-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for redis_exec_retry-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf185a8a41c48ca999a195551ac4682231a46aec1348fcfcba359d6c8c16b10a
MD5 592c4154af05ce92eb0c65597b3d708d
BLAKE2b-256 9bf8dc50d5828fdc398014d9c9b2c86f2e64909ae4ec7c0b6a4e752e21e51166

See more details on using hashes here.

Supported by

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