The pubsub example throws an exception if the specified topic does not already exist. Example:
>>>fromgcloudimportpubsub>>>client=pubsub.Client(project=MY_PROJECT_ID)
>>>topic=client.topic('my-new-custom-topic')
>>>topic.publish('Ping!')
Traceback (mostrecentcalllast):
File"<stdin>", line1, in<module>File"/usr/local/lib/python2.7/dist-packages/gcloud/pubsub/topic.py", line186, inpublishmethod='POST', path='%s:publish'% (self.path,), data=data)
File"/usr/local/lib/python2.7/dist-packages/gcloud/connection.py", line419, inapi_requesterror_info=method+' '+url)
gcloud.exceptions.NotFound: 404Resourcenotfound (resource=my-custom-topic). (POSThttps://pubsub.googleapis.com/v1/projects/lee-cloud/topics/my-custom-topic:publish)The code sample will resume working if you create the topic and re-run the sample, but it would be nice if the code sample included a line or two demonstrating how to create a topic if it doesn't exist.
The pubsub example throws an exception if the specified topic does not already exist. Example:
The code sample will resume working if you create the topic and re-run the sample, but it would be nice if the code sample included a line or two demonstrating how to create a topic if it doesn't exist.