diff --git a/samples/snippets/publisher.py b/samples/snippets/publisher.py index d527b54cb..465047560 100644 --- a/samples/snippets/publisher.py +++ b/samples/snippets/publisher.py @@ -30,15 +30,7 @@ def list_topics(): """Lists all Pub/Sub topics in the current project.""" pubsub_client = pubsub.Client() - topics = [] - next_page_token = None - while True: - page, next_page_token = pubsub_client.list_topics() - topics.extend(page) - if not next_page_token: - break - - for topic in topics: + for topic in pubsub_client.list_topics(): print(topic.name) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 7aa8ce1fb..f2fc2b4a2 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-pubsub==0.20.0 +google-cloud-pubsub==0.21.0 diff --git a/samples/snippets/subscriber.py b/samples/snippets/subscriber.py index b4fdd9573..9a564496e 100644 --- a/samples/snippets/subscriber.py +++ b/samples/snippets/subscriber.py @@ -31,15 +31,7 @@ def list_subscriptions(topic_name): pubsub_client = pubsub.Client() topic = pubsub_client.topic(topic_name) - subscriptions = [] - next_page_token = None - while True: - page, next_page_token = topic.list_subscriptions() - subscriptions.extend(page) - if not next_page_token: - break - - for subscription in subscriptions: + for subscription in topic.list_subscriptions(): print(subscription.name)