Skip to content

Commit 2dd4785

Browse files
Jon Wayne Parrottplamut
Jon Wayne Parrott
authored andcommitted
Update samples to support latest Google Cloud Python [(googleapis#656)](GoogleCloudPlatform/python-docs-samples#656)
1 parent 9555356 commit 2dd4785

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

samples/snippets/publisher.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,7 @@ def list_topics():
3030
"""Lists all Pub/Sub topics in the current project."""
3131
pubsub_client = pubsub.Client()
3232

33-
topics = []
34-
next_page_token = None
35-
while True:
36-
page, next_page_token = pubsub_client.list_topics()
37-
topics.extend(page)
38-
if not next_page_token:
39-
break
40-
41-
for topic in topics:
33+
for topic in pubsub_client.list_topics():
4234
print(topic.name)
4335

4436

samples/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-pubsub==0.20.0
1+
google-cloud-pubsub==0.21.0

samples/snippets/subscriber.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,7 @@ def list_subscriptions(topic_name):
3131
pubsub_client = pubsub.Client()
3232
topic = pubsub_client.topic(topic_name)
3333

34-
subscriptions = []
35-
next_page_token = None
36-
while True:
37-
page, next_page_token = topic.list_subscriptions()
38-
subscriptions.extend(page)
39-
if not next_page_token:
40-
break
41-
42-
for subscription in subscriptions:
34+
for subscription in topic.list_subscriptions():
4335
print(subscription.name)
4436

4537

0 commit comments

Comments
 (0)