-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.
Description
Attempting to pull from a subscription of an empty topic with return_immediately set to 'True' causes an exception to be raised. This should return an empty result, not raise a KeyError in the module, correct?
Example code:
#!/usr/bin/env python
from gcloud import pubsub
# Config
PUBSUB_TOPIC_NAME = 'deleteme'
PUBSUB_SUB_NAME = 'delete_me'
ack_queues = {}
client = pubsub.Client(project="joeholley-mimus01")
topic = client.topic(PUBSUB_TOPIC_NAME)
sub = topic.subscription(PUBSUB_SUB_NAME)
if not topic.exists():
topic.create()
if not sub.exists():
sub.create()
while True:
recv = sub.pull(return_immediately=True,max_messages=1)
print "Received!"
Results:
Traceback (most recent call last):
File "db/db_worker.py", line 135, in <module>
recv = sub.pull(return_immediately=True,max_messages=1)
File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/subscription.py", line 249, in pull
self.full_name, return_immediately, max_messages)
File "/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/connection.py", line 419, in subscription_pull
return response['receivedMessages']
KeyError: 'receivedMessages'
Expected results:
recv should contain an empty list as per http://googlecloudplatform.github.io/gcloud-python/stable/pubsub-subscription.html
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.