-
Notifications
You must be signed in to change notification settings - Fork 985
Add pyhive connection timeout #7300
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -160,7 +160,8 @@ def __init__( | |||||
| check_hostname=None, | ||||||
| ssl_cert=None, | ||||||
| thrift_transport=None, | ||||||
| ssl_context=None | ||||||
| ssl_context=None, | ||||||
| connection_timeout=None, | ||||||
| ): | ||||||
| """Connect to HiveServer2 | ||||||
|
|
||||||
|
|
@@ -175,6 +176,7 @@ def __init__( | |||||
| Incompatible with host, port, auth, kerberos_service_name, and password. | ||||||
| :param ssl_context: A custom SSL context to use for HTTPS connections. If provided, | ||||||
| this overrides check_hostname and ssl_cert parameters. | ||||||
| :param connection_timeout: Millisecond timeout for Thrift connections. Skipped if using thrift_transport. | ||||||
| The way to support LDAP and GSSAPI is originated from cloudera/Impyla: | ||||||
| https://github.com/cloudera/impyla/blob/255b07ed973d47a3395214ed92d35ec0615ebf62 | ||||||
| /impala/_thrift_api.py#L152-L160 | ||||||
|
|
@@ -193,6 +195,8 @@ def __init__( | |||||
| ), | ||||||
| ssl_context=ssl_context, | ||||||
| ) | ||||||
| if connection_timeout is not None: | ||||||
| thrift_transport.setTimeout(connection_timeout) | ||||||
|
|
||||||
| if auth in ("BASIC", "NOSASL", "NONE", None): | ||||||
| # Always needs the Authorization header | ||||||
|
|
@@ -236,6 +240,8 @@ def __init__( | |||||
| if auth is None: | ||||||
| auth = 'NONE' | ||||||
| socket = thrift.transport.TSocket.TSocket(host, port) | ||||||
| if connection_timeout is not None: | ||||||
| socket.setTimeout(connection_timeout) | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI this sets both connection and socket timeout. There's a nice description of the difference here.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good mention. My goal with this was originally to manage the socket timeout. However, I think I will leave this way to not get too granular. |
||||||
| if auth == 'NOSASL': | ||||||
| # NOSASL corresponds to hive.server2.authentication=NOSASL in hive-site.xml | ||||||
| self._transport = thrift.transport.TTransport.TBufferedTransport(socket) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.