Skip to content
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

add ConnectionPool.autoconnect #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

luyun-aa
Copy link

@luyun-aa luyun-aa commented Dec 5, 2016

@wbolster According to discussion in #143, this PR adds a autoconnect argument to ConnectionPool constructor.

Copy link
Member

@wbolster wbolster left a comment

Choose a reason for hiding this comment

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

overall, looks good

:param bool autoconnect: Whether a connection should be created upon
instantiation to test connection availability.
Note: the `autoconnect` flag of Connection instance inside the pool
is always False.
Copy link
Member

Choose a reason for hiding this comment

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

Can you rephrase the second part as "Note that this is unrelated to the autoconnect argument for connections, which is not applicable to connections managed by a connection pool." ? thanks

:param kwargs: keyword arguments passed to
:py:class:`happybase.Connection`
"""
def __init__(self, size, **kwargs):
def __init__(self, size, autoconnect=True, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

can you add a since comment (see other docstrings) to make clear when this api was added/changed?

if autoconnect:
# The first connection is made immediately so that trivial
# mistakes like unresolvable host names are raised immediately.
# Subsequent connections are connected lazily.
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: can you change this into

"Immediately open one connection so that trivial mistakes like unresolvable host names raise an exception upon pool instantiation instead of on first use. Subsequent connections are connected lazily."

@@ -487,6 +488,9 @@ def test_connection_pool_construction():
with assert_raises(ValueError):
ConnectionPool(size=0)

pool = ConnectionPool(size=1, autoconnect=False)
assert_is_none(getattr(pool._thread_connections, 'current'))

Copy link
Member

Choose a reason for hiding this comment

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

what are you trying to test here? it is not obvious to me :)

@wbolster
Copy link
Member

@luyun-aa is this still relevant? if so, please address my comments, and update the pr.

thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants