Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add simple retry policy with subclass of HTTPXRequest and change AsyncHTTPTransport init call (5 retries by default) #24 #29

Closed

Conversation

brunql
Copy link
Contributor

@brunql brunql commented Jun 9, 2024

Добавлен класс HTTPXRequestWithRetry унаследованный от HTTPXRequest, переопределен init для проброса retries в httpx.AsyncHTTPTransport.

Пробовал отключать сеть и смотреть логи, отрабатывает нормально:

telegram.error.NetworkError: httpx.ConnectError: [Errno -3] Temporary failure in name resolution
2024-06-09 14:51:22,558 - httpcore.connection - DEBUG - connect_tcp.started host='api.telegram.org' port=443 local_address=None timeout=5.0 socket_options=None
2024-06-09 14:51:22,561 - httpcore.connection - DEBUG - connect_tcp.failed exception=ConnectError(gaierror(-3, 'Temporary failure in name resolution'))
2024-06-09 14:51:22,561 - httpcore.connection - DEBUG - retry.started host='api.telegram.org' port=443 local_address=None timeout=5.0 socket_options=None
2024-06-09 14:51:22,561 - httpcore.connection - DEBUG - retry.complete
2024-06-09 14:51:22,561 - httpcore.connection - DEBUG - connect_tcp.started host='api.telegram.org' port=443 local_address=None timeout=5.0 socket_options=None
2024-06-09 14:51:22,562 - httpcore.connection - DEBUG - connect_tcp.failed exception=ConnectError(gaierror(-3, 'Temporary failure in name resolution'))

…e AsyncHTTPTransport init call (5 retries by default) #34
@brunql brunql changed the title feat: add simple retry policy with subclass of HTTPXRequest and change AsyncHTTPTransport init call (5 retries by default) #34 feat: add simple retry policy with subclass of HTTPXRequest and change AsyncHTTPTransport init call (5 retries by default) #24 Jun 9, 2024
@brunql
Copy link
Contributor Author

brunql commented Jun 9, 2024

Issue #24

@TyVik
Copy link
Collaborator

TyVik commented Jun 13, 2024

Я чуть подправил 48563a6. Там можно ещё глубже провалиться и переопределить всего лишь один метод, который и строит транспорт.

И кажется, что тот транспорт, что в init, строится никогда не будет, т.к. socket_options -- специфичная для ОС настройка, которая почти всегда None.

@brunql brunql closed this Jun 14, 2024
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