Skip to content

Commit 2ecd360

Browse files
author
Takashi Matsuo
authored
[spanner] fix: set timeout for polling on operations [(#3488)](GoogleCloudPlatform/python-docs-samples#3488)
* [spanner] fix: set timeout for polling on operations fixes #3471 * bump the deadline to 1200 for backup and restore * bumped the deadline to 120
1 parent ee0dca1 commit 2ecd360

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

samples/samples/backup_sample.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def create_backup(instance_id, database_id, backup_id):
4242
operation = backup.create()
4343

4444
# Wait for backup operation to complete.
45-
operation.result()
45+
operation.result(1200)
4646

4747
# Verify that the backup is ready.
4848
backup.reload()
@@ -68,7 +68,7 @@ def restore_database(instance_id, new_database_id, backup_id):
6868
operation = new_database.restore(backup)
6969

7070
# Wait for restore operation to complete.
71-
operation.result()
71+
operation.result(1200)
7272

7373
# Newly created database has restore information.
7474
new_database.reload()

samples/samples/snippets.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def create_database(instance_id, database_id):
5252
operation = database.create()
5353

5454
print('Waiting for operation to complete...')
55-
operation.result()
55+
operation.result(120)
5656

5757
print('Created database {} on instance {}'.format(
5858
database_id, instance_id))
@@ -213,7 +213,7 @@ def add_index(instance_id, database_id):
213213
'CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle)'])
214214

215215
print('Waiting for operation to complete...')
216-
operation.result()
216+
operation.result(120)
217217

218218
print('Added the AlbumsByAlbumTitle index.')
219219
# [END spanner_create_index]
@@ -306,7 +306,7 @@ def add_storing_index(instance_id, database_id):
306306
'STORING (MarketingBudget)'])
307307

308308
print('Waiting for operation to complete...')
309-
operation.result()
309+
operation.result(120)
310310

311311
print('Added the AlbumsByAlbumTitle2 index.')
312312
# [END spanner_create_storing_index]
@@ -355,7 +355,7 @@ def add_column(instance_id, database_id):
355355
'ALTER TABLE Albums ADD COLUMN MarketingBudget INT64'])
356356

357357
print('Waiting for operation to complete...')
358-
operation.result()
358+
operation.result(120)
359359

360360
print('Added the MarketingBudget column.')
361361
# [END spanner_add_column]
@@ -509,7 +509,7 @@ def create_table_with_timestamp(instance_id, database_id):
509509
])
510510

511511
print('Waiting for operation to complete...')
512-
operation.result()
512+
operation.result(120)
513513

514514
print('Created Performances table on database {} on instance {}'.format(
515515
database_id, instance_id))
@@ -554,7 +554,7 @@ def add_timestamp_column(instance_id, database_id):
554554
'OPTIONS(allow_commit_timestamp=true)'])
555555

556556
print('Waiting for operation to complete...')
557-
operation.result()
557+
operation.result(120)
558558

559559
print('Altered table "Albums" on database {} on instance {}.'.format(
560560
database_id, instance_id))
@@ -1122,7 +1122,7 @@ def create_table_with_datatypes(instance_id, database_id):
11221122
])
11231123

11241124
print('Waiting for operation to complete...')
1125-
operation.result()
1125+
operation.result(120)
11261126

11271127
print('Created Venues table on database {} on instance {}'.format(
11281128
database_id, instance_id))

0 commit comments

Comments
 (0)