Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion pubsub/cloud-client/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def publish_messages_with_error_handler(project, topic_name):
topic_path = publisher.topic_path(project, topic_name)

def callback(message_future):
if message_future.exception():
# When timeout is unspecified, the exception method waits indefinitely.
if message_future.exception(timeout=30):
print('Publishing message on {} threw an Exception {}.'.format(
topic_name, message_future.exception()))
else:
Expand Down
4 changes: 2 additions & 2 deletions pubsub/cloud-client/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ def callback(message):
# Blocks the thread while messages are coming in through the stream. Any
# exceptions that crop up on the thread will be set on the future.
try:
subscription.future.result()
# When timeout is unspecified, the result method waits indefinitely.
subscription.future.result(timeout=30)
except Exception as e:
print(
'Listening for messages on {} threw an Exception: {}.'.format(
subscription_name, e))
raise
# [END pubsub_subscriber_error_listener]


Expand Down