How to use Pubsub Emulator with PublisherClient from google-cloud-pubsub version 0.28

Question:

I just update to google-cloud-pubsub version 0.28, where Google restructured the Python client into a PublisherClient and SubscriberClient. I was trying to connect to the Pubsub Emulator on localhost, but despite setting the environment variables, it still connects to the cloud pubsub service, where it can list all the topic from cloud pubsub, but not the ones from emulator.

Here is the code I used to connect to emulator

from google.cloud import pubsub
import os
os.environ['PUBSUB_EMULATOR_HOST'] = 'localhost:8085'
os.environ['GOOGLE_CLOUD_PROJECT'] = 'my-project'
publisher = pubsub.PublisherClient()
topic = 'projects/my-project/topics/abc'
publisher.get_topic(topic)

and here is the exception:

Traceback (most recent call last):
  File "<input>", line 5, in <module>
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/cloud/pubsub_v1/_gapic.py", line 42, in <lambda>
    fx = lambda self, *a, **kw: wrapped_fx(self.api, *a, **kw)
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/cloud/gapic/pubsub/v1/publisher_client.py", line 341, in get_topic
    return self._get_topic(request, options)
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/gax/api_callable.py", line 452, in inner
    return api_caller(api_call, this_settings, request)
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/gax/api_callable.py", line 438, in base_caller
    return api_call(*args)
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/gax/api_callable.py", line 376, in inner
    return a_func(*args, **kwargs)
  File "/Users/sx5640/Envs/uie/lib/python2.7/site-packages/google/gax/retry.py", line 127, in inner
    ' classified as transient', exception)
RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.NOT_FOUND, Resource not found (resource=abc).)>)
Asked By: xiu shi

||

Answers:

The issue was fixed in verion 0.29

Answered By: xiu shi