-
Notifications
You must be signed in to change notification settings - Fork 436
Add custom session injection, Fix bug for http_options #1119
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
Conversation
* ssl-verify is an option, not a header
* Allow injection of session_factory to allow use of a custom session
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I love the session factory approach to be honest. It feels like a pretty advanced use case. We also aren't sure that the http_options interface we have is going to work with or apply to every possible session type .
If we really do want support that case. I think it's slightly safer/more-robust if we:
- Make
session_factory
a kw-only argument, and make the defaultNone
. - Then in the
__init__
method if factory is None use requests.session
I think that makes it less likely to accidentally set it, and protect against an oopsie in changing the signature in the future
Regardless, for the http_options bit, left a few comments
tableauserverclient/server/server.py
Outdated
@@ -60,12 +54,13 @@ class PublishMode: | |||
Overwrite = "Overwrite" | |||
CreateNew = "CreateNew" | |||
|
|||
def __init__(self, server_address, use_server_version=False, http_options=None): | |||
def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=requests.Session): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, server_address, use_server_version=False, http_options=None, session_factory=requests.Session): | |
def __init__(self, server_address, use_server_version=False, http_options=None, *, session_factory=None): | |
if session_factory is None: | |
self._session = requests.Session() | |
else: | |
self._session = session_factory() |
Pylint with "errors only" isn't 100% accurate, but it found a few problems that should be fixed.
No description provided.