From d9f544a9174066445141baacb80516487812ac83 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Thu, 16 Jun 2016 13:36:03 -0700 Subject: [PATCH] Close HappyBase connection in bigtable/hello sample. I noticed that the `bigtable/hello` sample was not quitting when I sent a `Ctrl-C` this should fix that problem. --- bigtable/hello/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bigtable/hello/main.py b/bigtable/hello/main.py index 73ce1784a220..fc6ff6bb1e32 100644 --- a/bigtable/hello/main.py +++ b/bigtable/hello/main.py @@ -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' @@ -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__':