Skip to content

Commit

Permalink
added retry mechanism to the retry flow
Browse files Browse the repository at this point in the history
  • Loading branch information
antikus committed Oct 19, 2023
1 parent 8897fb6 commit 06918fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.6.18

* Added retry mechanism for the authentication flow.

## v0.6.17

* Removed unnecessary dependencies of the SDK, bumped Pyarrow to v10.
Expand Down
2 changes: 1 addition & 1 deletion railib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version_info__ = (0, 6, 17)
__version_info__ = (0, 6, 18)
__version__ = ".".join(map(str, __version_info__))
16 changes: 9 additions & 7 deletions railib/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,15 @@ def _request_access_token(ctx: Context, url: str) -> AccessToken:
data=data,
)
_print_request(req)
with urlopen(req) as rsp:
result = json.loads(rsp.read())
token = result.get(ACCESS_KEY_TOKEN_KEY, None)
if token is not None:
expires_in = result.get(EXPIRES_IN_KEY, None)
scope = result.get(SCOPE, None)
return AccessToken(token, scope, expires_in)
rsp = _urlopen_with_retry(req, ctx.retries)
result = json.loads(rsp.read())
token = result.get(ACCESS_KEY_TOKEN_KEY, None)

if token is not None:
expires_in = result.get(EXPIRES_IN_KEY, None)
scope = result.get(SCOPE, None)
return AccessToken(token, scope, expires_in)

raise Exception("failed to get the access token")


Expand Down

0 comments on commit 06918fb

Please sign in to comment.