René's URL Explorer Experiment


Title: additional fix for 504 errors · Issue #528 · massive-com/client-python · GitHub

Open Graph Title: additional fix for 504 errors · Issue #528 · massive-com/client-python

X Title: additional fix for 504 errors · Issue #528 · massive-com/client-python

Description: Describe the bug @justinpolygon I found another place in the code that needs to be updated in order for the new #525 retry logic to work properly. The following line (a remnant of the old code) needs to be removed: https://github.com/pol...

Open Graph Description: Describe the bug @justinpolygon I found another place in the code that needs to be updated in order for the new #525 retry logic to work properly. The following line (a remnant of the old code) nee...

X Description: Describe the bug @justinpolygon I found another place in the code that needs to be updated in order for the new #525 retry logic to work properly. The following line (a remnant of the old code) nee...

Opengraph URL: https://github.com/massive-com/client-python/issues/528

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"additional fix for 504 errors","articleBody":"**Describe the bug**\r\n@justinpolygon I found another place in the code that needs to be updated in order for the new #525 retry logic to work properly. The following line (a remnant of the old code) needs to be removed:\r\n\r\nhttps://github.com/polygon-io/client-python/blob/master/polygon/rest/base.py#L113\r\n\r\nThis line effectively overrides the new retry_strategy object specified in the urllib3.PoolManager initialization line, so it prevents that logic from taking effect. I discovered this when I backed out my tenacity workaround and got a 504 error last night.\r\n\r\n**To Reproduce**\r\nI found a way to reproduce this problem by monkey-patching the `_make_request` method in urllib3 to randomly return 504 instead of the actual error code, which forces an exercise of the retry logic. To implement this test, make the following change to polygon/rest/base.py. Right after the import urllib3 line, insert the following code:\r\n\r\n```python\r\noriginal_make_request = urllib3.connectionpool.HTTPConnectionPool._make_request\r\ndef monkey_patched_make_request(self, conn, method, url, **kwargs):\r\n    response = original_make_request(self, conn, method, url, **kwargs)\r\n    import random\r\n    if random.random() \u003c 0.90: response.status = 504\r\n    return response\r\nurllib3.connectionpool.HTTPConnectionPool._make_request = monkey_patched_make_request\r\n```\r\n\r\nHere is a sample script to test the library with the above change:\r\n\r\n```python\r\nimport polygon\r\nfrom pprint import pprint\r\n\r\npolygon_api = polygon.RESTClient(POLYGON_KEY_REDACTED, retries=2, trace=True, verbose=True)\r\n\r\ntrades = [*polygon_api.list_trades('AAPL', timestamp_gt=1695944980000000000, timestamp_lte=1695945000000000000)]\r\npprint(trades)\r\n```\r\n\r\nWith the current code, running the sample script results in the following kind of intermittent error, which indicates that retries aren't actually happening:\r\n\r\n```\r\npolygon.exceptions.BadResponse: {\"results\"': [...]}\r\n```\r\n\r\nWhen I delete line 113 from polygon/rest/base.api, I get a totally different intermittent error:\r\n\r\n```\r\nurllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.polygon.io', port=443): Max retries exceeded with url: /v3/trades/AAPL?timestamp.lte=1695945000000000000\u0026timestamp.gt=1695944980000000000 (Caused by ResponseError('too many 504 error responses'))\r\n```\r\nThis indicates that the retries are actually happening.","author":{"url":"https://github.com/kartiksubbarao","@type":"Person","name":"kartiksubbarao"},"datePublished":"2023-09-29T01:48:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/528/client-python/issues/528"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cff6b1d1-50b7-7270-cbdb-e5d2993dc943
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE38E:4D83E:D76FA0:127DAB5:6A4DD0AE
html-safe-nonce35683bae3609d998ce870e8b26003a20e61edb96713a45cc251d459bbf068e7b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzhFOjREODNFOkQ3NkZBMDoxMjdEQUI1OjZBNEREMEFFIiwidmlzaXRvcl9pZCI6IjU2Mjg2MTc0MTg0MzM0ODI5MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac1409c1323821ce51e046623fd3ca58b373ae764828cc5fd4d3f786dbc6317ea3
hovercard-subject-tagissue:1918482739
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/massive-com/client-python/528/issue_layout
twitter:imagehttps://opengraph.githubassets.com/baa8602ca3046846d51ad005c5c15e9452ff09df7878ebd99c3ec47f832599dd/massive-com/client-python/issues/528
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/baa8602ca3046846d51ad005c5c15e9452ff09df7878ebd99c3ec47f832599dd/massive-com/client-python/issues/528
og:image:altDescribe the bug @justinpolygon I found another place in the code that needs to be updated in order for the new #525 retry logic to work properly. The following line (a remnant of the old code) nee...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekartiksubbarao
hostnamegithub.com
expected-hostnamegithub.com
None06b8a6144231bf3a234f1c2e9993861e07ce98a905912b114aa386c2d7e84b33
turbo-cache-controlno-preview
go-importgithub.com/massive-com/client-python git https://github.com/massive-com/client-python.git
octolytics-dimension-user_id191946194
octolytics-dimension-user_loginmassive-com
octolytics-dimension-repository_id216660192
octolytics-dimension-repository_nwomassive-com/client-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id216660192
octolytics-dimension-repository_network_root_nwomassive-com/client-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1d344bdb7547fe6bca17a59bb2b8aac3dc9532a0
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/massive-com/client-python/issues/528#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmassive-com%2Fclient-python%2Fissues%2F528
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmassive-com%2Fclient-python%2Fissues%2F528
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=massive-com%2Fclient-python
Reloadhttps://github.com/massive-com/client-python/issues/528
Reloadhttps://github.com/massive-com/client-python/issues/528
Reloadhttps://github.com/massive-com/client-python/issues/528
Please reload this pagehttps://github.com/massive-com/client-python/issues/528
massive-com https://github.com/massive-com
client-pythonhttps://github.com/massive-com/client-python
Notifications https://github.com/login?return_to=%2Fmassive-com%2Fclient-python
Fork 356 https://github.com/login?return_to=%2Fmassive-com%2Fclient-python
Star 1.5k https://github.com/login?return_to=%2Fmassive-com%2Fclient-python
Code https://github.com/massive-com/client-python
Issues 12 https://github.com/massive-com/client-python/issues
Pull requests 6 https://github.com/massive-com/client-python/pulls
Actions https://github.com/massive-com/client-python/actions
Security and quality 0 https://github.com/massive-com/client-python/security
Insights https://github.com/massive-com/client-python/pulse
Code https://github.com/massive-com/client-python
Issues https://github.com/massive-com/client-python/issues
Pull requests https://github.com/massive-com/client-python/pulls
Actions https://github.com/massive-com/client-python/actions
Security and quality https://github.com/massive-com/client-python/security
Insights https://github.com/massive-com/client-python/pulse
#529https://github.com/massive-com/client-python/pull/529
additional fix for 504 errorshttps://github.com/massive-com/client-python/issues/528#top
#529https://github.com/massive-com/client-python/pull/529
bugSomething isn't workinghttps://github.com/massive-com/client-python/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com/kartiksubbarao
kartiksubbaraohttps://github.com/kartiksubbarao
on Sep 29, 2023https://github.com/massive-com/client-python/issues/528#issue-1918482739
@justinpolygonhttps://github.com/justinpolygon
#525https://github.com/massive-com/client-python/issues/525
https://github.com/polygon-io/client-python/blob/master/polygon/rest/base.py#L113https://github.com/polygon-io/client-python/blob/master/polygon/rest/base.py#L113
bugSomething isn't workinghttps://github.com/massive-com/client-python/issues?q=state%3Aopen%20label%3A%22bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.