Title: library does not retry on 504 timeout errors · Issue #525 · massive-com/client-python · GitHub
Open Graph Title: library does not retry on 504 timeout errors · Issue #525 · massive-com/client-python
X Title: library does not retry on 504 timeout errors · Issue #525 · massive-com/client-python
Description: Describe the bug Even with retries=10 specified when creating the client object, the library doesn't seem to retry on 504 timeout errors. For example, a couple times last week I got a polygon.exceptions.BadResponse exception: File "/path...
Open Graph Description: Describe the bug Even with retries=10 specified when creating the client object, the library doesn't seem to retry on 504 timeout errors. For example, a couple times last week I got a polygon.excep...
X Description: Describe the bug Even with retries=10 specified when creating the client object, the library doesn't seem to retry on 504 timeout errors. For example, a couple times last week I got a polygon.e...
Opengraph URL: https://github.com/massive-com/client-python/issues/525
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"library does not retry on 504 timeout errors","articleBody":"**Describe the bug**\r\nEven with retries=10 specified when creating the client object, the library doesn't seem to retry on 504 timeout errors. For example, a couple times last week I got a polygon.exceptions.BadResponse exception:\r\n```\r\n File \"/path/to/lib64/python3.11/site-packages/polygon/rest/base.py\", line 192, in _paginate_iter\r\n resp = self._get(\r\n ^^^^^^^^^^\r\n File \"/path/to/lib64/python3.11/site-packages/polygon/rest/base.py\", line 110, in _get\r\n raise BadResponse(resp.data.decode(\"utf-8\"))\r\npolygon.exceptions.BadResponse: \u003chtml\u003e\r\n\u003chead\u003e\u003ctitle\u003e504 Gateway Time-out\u003c/title\u003e\u003c/head\u003e\r\n\u003cbody\u003e\r\n\u003ccenter\u003e\u003ch1\u003e504 Gateway Time-out\u003c/h1\u003e\u003c/center\u003e\r\n\u003chr\u003e\u003ccenter\u003enginx/1.19.2\u003c/center\u003e\r\n\u003c/body\u003e\r\n\u003c/html\u003e\r\n```\r\n\r\nThe core issue I think is that polygon's retry logic only retries for the default set of codes that urllib3 recognizes for retries (413, 429, 503). Adding 504 could be a simple fix.\r\n\r\nJust FYI for anyone else who is seeing this issue -- I'm currently using the tenacity library as a workaround:\r\n\r\n```python\r\ndef is_504(exception):\r\n return isinstance(exception, polygon.exceptions.BadResponse) \\\r\n and '504 Gateway Time-out' in str(exception)\r\npolygon_retry = tenacity.retry(retry=(tenacity.retry_if_exception(is_504)),\r\n stop=tenacity.stop_after_attempt(10))\r\n```\r\nAnd then using `@polygon_retry` as a decorator for functions that call polygon library methods.\r\n\r\n**To Reproduce**\r\nIt's difficult to reproduce this problem since it doesn't happen very often. One way to reproduce it might be to create a mock API server that returns 504s.\r\n\r\n**Expected behavior**\r\nExpected behavior is for the polygon library to handle the timeout itself (based on the retries argument).","author":{"url":"https://github.com/kartiksubbarao","@type":"Person","name":"kartiksubbarao"},"datePublished":"2023-09-27T13:07:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/525/client-python/issues/525"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:853a1df0-8505-d7be-292d-4e658949b8f4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E984:6697C:EB0CA:157AD8:6A4DFB61 |
| html-safe-nonce | e0a5e0532c0247b7cd1cb0c15e03fa329e82fbce7b813daf7442fa04164b91c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTg0OjY2OTdDOkVCMENBOjE1N0FEODo2QTRERkI2MSIsInZpc2l0b3JfaWQiOiIyNzYyMjg1OTIzMDMwNjYxOTg1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 05f643689fdacb21489700ae5415c37a89570a0d7be0e8ba947aaeba5fb20923 |
| hovercard-subject-tag | issue:1915552523 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/massive-com/client-python/525/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2d80f9b25f018c6836fdefc8e64238aa0f8b25311a03a5c9c52d64209a729644/massive-com/client-python/issues/525 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2d80f9b25f018c6836fdefc8e64238aa0f8b25311a03a5c9c52d64209a729644/massive-com/client-python/issues/525 |
| og:image:alt | Describe the bug Even with retries=10 specified when creating the client object, the library doesn't seem to retry on 504 timeout errors. For example, a couple times last week I got a polygon.excep... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kartiksubbarao |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/massive-com/client-python git https://github.com/massive-com/client-python.git |
| octolytics-dimension-user_id | 191946194 |
| octolytics-dimension-user_login | massive-com |
| octolytics-dimension-repository_id | 216660192 |
| octolytics-dimension-repository_nwo | massive-com/client-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 216660192 |
| octolytics-dimension-repository_network_root_nwo | massive-com/client-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4314b1df11fa8a565684f3a72dc971e3785da365 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width