Skip to content

Bug/pla 3008 notebook connection reset error#253

Merged
mcgalcode merged 3 commits intomasterfrom
bug/PLA-3008-notebook-connection-reset-error
Mar 12, 2020
Merged

Bug/pla 3008 notebook connection reset error#253
mcgalcode merged 3 commits intomasterfrom
bug/PLA-3008-notebook-connection-reset-error

Conversation

@crleblanc
Copy link
Copy Markdown
Contributor

Citrine Python PR

Description

This PR is a proposed bugfix for https://citrine.atlassian.net/browse/PLA-3008. If a ConnectionResetError or ConnectionError exception is raised while running a request, this will reinitialize the session and try the request again. This does not use recursion.

I view this as a low risk PR as there is no substantial change to the logic.

PR Type:

  • Breaking change (fix or feature that would cause existing functionality to change)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Adherence to team decisions

  • I have added tests for 100% coverage
  • I have written Numpy-style docstrings for every method and class.
  • I have communicated the downstream consequences of the PR to others.

@crleblanc crleblanc requested a review from mcgalcode March 12, 2020 21:36
@crleblanc crleblanc self-assigned this Mar 12, 2020
Copy link
Copy Markdown
Contributor

@jfriend-citrine jfriend-citrine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Let's find a resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback.

Comment thread src/citrine/_session.py
response = super().request(method, uri, **kwargs)
except (ConnectionError, ConnectionResetError):
logger.debug('Connection Error, creating a new session')
super().__init__()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly does this do? Does this reset the state of the citrine session? How are the parameters that were used to instantiate the citrine session (e.g. scheme, host, api key) persisted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The citrine-python Session is a subclass of Requests.Session. The CP Session.init() calls the superclass's (Requests.Session's) init() with no arguments. I had a look as Request's Session.init() and this is where urllib3 connections are created.

All of the arguments passed to CP's Session.init() are left unchanged so they should persist as normal. I'm not sure which attributes are used by the superclass, e.g. refresh_token.

This PR doesn't try to refresh the token if one of these errors are seen. This is something we can look into if required.

This change has not been tested with Jupyter notebooks to see if this addresses the possible timeout issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. This sounds great to me. I'll merge.

@mcgalcode mcgalcode merged commit b86893e into master Mar 12, 2020
@kroenlein kroenlein deleted the bug/PLA-3008-notebook-connection-reset-error branch January 7, 2022 00:35
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.

3 participants