Skip to content

feat: Add retry logic with exponential backoff #3

@CaptainDriftwood

Description

@CaptainDriftwood

Summary

Add configurable retry logic with exponential backoff for transient failures.

Motivation

  • Network issues can cause temporary connection failures
  • ICAP servers may be temporarily unavailable during updates/restarts
  • Production environments need resilience against transient errors

Proposed Implementation

  • Add retries and backoff_factor parameters to IcapClient
  • Retry on IcapConnectionError and IcapTimeoutError
  • Use exponential backoff: delay = backoff_factor * (2 ** attempt)
  • Make retry behavior configurable (max retries, which exceptions to retry)

Example Usage

from pycap import IcapClient

# Retry up to 3 times with exponential backoff
client = IcapClient(
    'localhost',
    retries=3,
    backoff_factor=0.5  # 0.5s, 1s, 2s delays
)

with client:
    response = client.scan_file('/path/to/file.pdf')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions