{"action":"created","issue":{"url":"https://api.github.com/repos/stripe/stripe-python/issues/470","repository_url":"https://api.github.com/repos/stripe/stripe-python","labels_url":"https://api.github.com/repos/stripe/stripe-python/issues/470/labels{/name}","comments_url":"https://api.github.com/repos/stripe/stripe-python/issues/470/comments","events_url":"https://api.github.com/repos/stripe/stripe-python/issues/470/events","html_url":"https://github.com/stripe/stripe-python/pull/470","id":357883537,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzNzkwNjE0","number":470,"title":"Python retry mechanism","user":{"login":"mickjermsurawong-stripe","id":42550941,"node_id":"MDQ6VXNlcjQyNTUwOTQx","avatar_url":"https://avatars0.githubusercontent.com/u/42550941?v=4","gravatar_id":"","url":"https://api.github.com/users/mickjermsurawong-stripe","html_url":"https://github.com/mickjermsurawong-stripe","followers_url":"https://api.github.com/users/mickjermsurawong-stripe/followers","following_url":"https://api.github.com/users/mickjermsurawong-stripe/following{/other_user}","gists_url":"https://api.github.com/users/mickjermsurawong-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/mickjermsurawong-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mickjermsurawong-stripe/subscriptions","organizations_url":"https://api.github.com/users/mickjermsurawong-stripe/orgs","repos_url":"https://api.github.com/users/mickjermsurawong-stripe/repos","events_url":"https://api.github.com/users/mickjermsurawong-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/mickjermsurawong-stripe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"mickjermsurawong-stripe","id":42550941,"node_id":"MDQ6VXNlcjQyNTUwOTQx","avatar_url":"https://avatars0.githubusercontent.com/u/42550941?v=4","gravatar_id":"","url":"https://api.github.com/users/mickjermsurawong-stripe","html_url":"https://github.com/mickjermsurawong-stripe","followers_url":"https://api.github.com/users/mickjermsurawong-stripe/followers","following_url":"https://api.github.com/users/mickjermsurawong-stripe/following{/other_user}","gists_url":"https://api.github.com/users/mickjermsurawong-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/mickjermsurawong-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mickjermsurawong-stripe/subscriptions","organizations_url":"https://api.github.com/users/mickjermsurawong-stripe/orgs","repos_url":"https://api.github.com/users/mickjermsurawong-stripe/repos","events_url":"https://api.github.com/users/mickjermsurawong-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/mickjermsurawong-stripe/received_events","type":"User","site_admin":false},"assignees":[{"login":"mickjermsurawong-stripe","id":42550941,"node_id":"MDQ6VXNlcjQyNTUwOTQx","avatar_url":"https://avatars0.githubusercontent.com/u/42550941?v=4","gravatar_id":"","url":"https://api.github.com/users/mickjermsurawong-stripe","html_url":"https://github.com/mickjermsurawong-stripe","followers_url":"https://api.github.com/users/mickjermsurawong-stripe/followers","following_url":"https://api.github.com/users/mickjermsurawong-stripe/following{/other_user}","gists_url":"https://api.github.com/users/mickjermsurawong-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/mickjermsurawong-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mickjermsurawong-stripe/subscriptions","organizations_url":"https://api.github.com/users/mickjermsurawong-stripe/orgs","repos_url":"https://api.github.com/users/mickjermsurawong-stripe/repos","events_url":"https://api.github.com/users/mickjermsurawong-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/mickjermsurawong-stripe/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2018-09-07T01:10:01Z","updated_at":"2018-09-07T20:43:48Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/stripe/stripe-python/pulls/470","html_url":"https://github.com/stripe/stripe-python/pull/470","diff_url":"https://github.com/stripe/stripe-python/pull/470.diff","patch_url":"https://github.com/stripe/stripe-python/pull/470.patch"},"body":"Summary:\r\n- Implement retry mechanism at abstract HTTPClient class, and use delegated request call to each client implementation.   \r\n- Only consider errors from `requests` http-client, but not others due to overwhelming majority of our clients. This design allows future extension the support to other http-clients. (As opposed to urllib3 `Retry` that is coupled at the execution invocation.\r\n- Retry conditions follow other language implementations (Ruby[0]/Go[1]) \r\n  - Retry on 409 resource conflict (both)\r\n  - Retry on timeout/connection (only Ruby) \r\n- Exponential backoff delay follows other language implementations (Ruby[2]/Go[3])\r\n- Added idempotency key only for POST method, and when it is not given in the header\r\n\r\nConcerns:\r\n- Not sure where's best to put delay constants in config. Currently made as static class var\r\n- I'm not sure how to access the actual `requests` module from within test, and that results in mocking kinds of exception classes that we want to handle (existing tests also rely on the similar mechanism)\r\n\r\nMotivation:\r\n- Issue https://github.com/stripe/stripe-python/issues/464 and from conversation in PR https://github.com/stripe/stripe-python/pull/466 \r\n\r\n[0] Ruby retry conditions\r\nhttps://github.com/stripe/stripe-ruby/blob/ec66c3f0f44274f885de8d13de5dce2657932121/lib/stripe/stripe_client.rb#L61\r\n[1] Go retry conditions\r\nhttps://github.com/stripe/stripe-go/blob/442690c3856640e4913163f506f0070561f3368d/stripe.go#L495\r\n[2] Ruby sleep\r\nhttps://github.com/stripe/stripe-ruby/blob/ec66c3f0f44274f885de8d13de5dce2657932121/lib/stripe/stripe_client.rb#L80\r\n[3] Go sleep\r\nhttps://github.com/stripe/stripe-go/blob/442690c3856640e4913163f506f0070561f3368d/stripe.go#L511\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/stripe/stripe-python/issues/comments/419560458","html_url":"https://github.com/stripe/stripe-python/pull/470#issuecomment-419560458","issue_url":"https://api.github.com/repos/stripe/stripe-python/issues/470","id":419560458,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTU2MDQ1OA==","user":{"login":"mickjermsurawong-stripe","id":42550941,"node_id":"MDQ6VXNlcjQyNTUwOTQx","avatar_url":"https://avatars0.githubusercontent.com/u/42550941?v=4","gravatar_id":"","url":"https://api.github.com/users/mickjermsurawong-stripe","html_url":"https://github.com/mickjermsurawong-stripe","followers_url":"https://api.github.com/users/mickjermsurawong-stripe/followers","following_url":"https://api.github.com/users/mickjermsurawong-stripe/following{/other_user}","gists_url":"https://api.github.com/users/mickjermsurawong-stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/mickjermsurawong-stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mickjermsurawong-stripe/subscriptions","organizations_url":"https://api.github.com/users/mickjermsurawong-stripe/orgs","repos_url":"https://api.github.com/users/mickjermsurawong-stripe/repos","events_url":"https://api.github.com/users/mickjermsurawong-stripe/events{/privacy}","received_events_url":"https://api.github.com/users/mickjermsurawong-stripe/received_events","type":"User","site_admin":false},"created_at":"2018-09-07T20:43:48Z","updated_at":"2018-09-07T20:43:48Z","author_association":"NONE","body":"Added comment/logging\r\nptal @brandur-stripe "}}
{"actor":{"display_login":"mickjermsurawong-stripe"}}