Skip to content

Close HappyBase connection in bigtable/hello sample. #377

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 1 commit into from
Jun 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions bigtable/hello/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ def main(project_id, cluster_id, zone, table_name):
# The client must be created with admin=True because it will create a
# table.
client = bigtable.Client(project=project_id, admin=True)
cluster = client.cluster(zone, cluster_id)
connection = happybase.Connection(cluster=cluster)
# [END connecting_to_bigtable]

with client:
cluster = client.cluster(zone, cluster_id)
cluster.reload()
connection = happybase.Connection(cluster=cluster)
# [END connecting_to_bigtable]

try:
# [START creating_a_table]
print('Creating the {} table.'.format(table_name))
column_family_name = 'cf1'
Expand Down Expand Up @@ -95,6 +93,8 @@ def main(project_id, cluster_id, zone, table_name):
print('Deleting the {} table.'.format(table_name))
connection.delete_table(table_name)
# [END deleting_a_table]
finally:
connection.close()


if __name__ == '__main__':
Expand Down