Skip to content

Comments

automatically retry connection errors#190

Merged
frankh merged 3 commits intomasterfrom
frank/retry-connection-errors
Feb 12, 2025
Merged

automatically retry connection errors#190
frankh merged 3 commits intomasterfrom
frank/retry-connection-errors

Conversation

@frankh
Copy link
Contributor

@frankh frankh commented Feb 12, 2025

from the docs for max_retries: this applies only to failed DNS lookups,
socket connections and connection timeouts

@frankh frankh requested a review from daibhin February 12, 2025 11:40
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds automatic retry functionality for connection errors in the PostHog Python client, implementing basic retry logic for network-related failures.

  • Added HTTPAdapter with max_retries=2 in /posthog/request.py to handle failed DNS lookups, socket connections and timeouts
  • Mounted adapter specifically to HTTPS protocol via _session.mount('https://', adapter)
  • Version bumped to 3.13.0 in /posthog/version.py to reflect new feature addition
  • Clear documentation added in CHANGELOG.md about the automatic retry capability

3 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 15 to 17
adapter = HTTPAdapter(max_retries=2)
_session = requests.sessions.Session()
_session.mount('https://', adapter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider mounting the adapter for both 'http://' and 'https://' protocols to handle all potential connection types.

@frankh frankh force-pushed the frank/retry-connection-errors branch from 0e87219 to 71bc7ff Compare February 12, 2025 11:42
@frankh frankh force-pushed the frank/retry-connection-errors branch 2 times, most recently from 275d648 to 9734403 Compare February 12, 2025 11:49
from the docs for max_retries: this applies only to failed DNS lookups,
 socket connections and connection timeouts
@frankh frankh force-pushed the frank/retry-connection-errors branch from 9734403 to 6b9bdc7 Compare February 12, 2025 11:49
@frankh frankh merged commit 1b57a96 into master Feb 12, 2025
6 checks passed
@frankh frankh deleted the frank/retry-connection-errors branch February 12, 2025 12:29
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.

2 participants