Skip to content

BREAKING CHANGE: uses raise_for_status for requests #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2025

Conversation

jtyoung84
Copy link
Contributor

@jtyoung84 jtyoung84 commented Feb 13, 2025

Closes #6
Closes #108

  • Allows user to pass in requests.Session object
  • Uses raise_for_status for requests exceptions (This will introduce a breaking change if users added error handlers in their code)
  • Updates some urls in tests to be example.com
  • Adds lower bound to aind-data-schema
  • Changes cached_property to property
  • Updates internal property names
  • Moves boto3 to core requirement since it's required to use the docdb write methods

@bjhardcastle
Copy link
Member

This is a great addition, thank you!

We might want to reconsider the use of the cached_property decorator for __requests_session (and for __boto_session), which has a pretty serious problem for concurrent processing described here: python/cpython#87634
All instances of the class will share the same lock, blocking each other any time the cached property is accessed. This will definitely hurt performance if a user creates a threadpool to run many queries together.

It could be avoided by rearranging the current code, but keeping the same logic and sequence of operations:

class Client:

    def __init__(
        self,
        ...
        requests_session=None,
    ):
        ...
        self._requests_session = requests_session

    @property
    def __requests_session(self):
        """Requests session"""
        if self._requests_session is None:
            self._requests_session = Session()
        return self._requests_session

@jtyoung84 jtyoung84 merged commit c8d100a into dev Feb 14, 2025
3 checks passed
@jtyoung84 jtyoung84 deleted the feat-6-error-handlers branch February 14, 2025 00:17
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.

Add retries Add better error handlers
2 participants