Skip to content

Conversation

@andi-bigswitch
Copy link
Contributor

Summary

  • Add retries parameter to pybsn.connect() for automatic retry of failed HTTP requests
  • Accepts None (default, no retries), int (simple retry count), or urllib3.util.retry.Retry object
  • Mounts HTTPAdapter with retry configuration on the session
  • Maintains full backward compatibility (retries=None preserves existing behavior)

Implementation

  • Added RetriesType type alias and retry parameter to connect() function
  • HTTPAdapter with retry config is mounted for both http:// and https:// schemes after TLS verification is set
  • Added comprehensive docstring documentation explaining retry behavior and limitations

Testing

  • Created 13 new tests across 3 test files
  • test_retry_connect.py - Connection setup and configuration (7 tests)
  • test_retry_bigdbclient.py - Method-level retry behavior (9 tests)
  • test_retry_bigdbclient_integration.py - Integration scenarios (8 tests)
  • All 109 tests pass (including existing tests)
  • Code formatting, linting, and type checking pass
  • Added examples/retry_example.py with 4 usage examples
  • Updated README.md with retry configuration documentation

🤖 Generated with Claude Code

Fixes: BUG1290387

andi-bigswitch and others added 2 commits October 13, 2025 14:30
Network connections can fail transiently due to temporary issues. This adds
a retries parameter to enable automatic retry behavior with exponential backoff,
improving reliability of HTTP clients without requiring manual HTTPAdapter configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The initial documentation was misleading about what retries=3 does.
This commit fixes the documentation and adds validation tests.

Key clarifications:
- retries=3 only retries GET, HEAD, OPTIONS, PUT, DELETE, TRACE
- POST and PATCH are NOT retried even on connection errors
- Integer values do NOT retry on HTTP status codes (only connection errors)
- allowed_methods restricts retries for ALL failure types, not just status codes

Changes:
- Updated docstring with precise behavior description
- Updated README with accurate documentation and warnings
- Updated example comments to match tested behavior
- Added test_retry_behavior_validation.py (6 tests) - validates configuration
- Added test_retry_real_server.py (3 tests) - real HTTP server integration tests

All 118 tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant