When running locally with gcloud auth providing application default credentials, pubsub is unable to infer a connection, so this will fail:
import pubsub
pubsub.set_default_project('my-project-id')
topic = pubsub.Topic('my-topic')
topic.publish(...)
with EnvironmentError: Connection could not be inferred.
The fix is to set an explicit connection using adc:
credentials = GoogleCredentials.get_application_default()
pubsub.set_default_connection(pubsub.Connection(credentials))
However, storage and datastore do not have this issue. It seems unnecessarily to do this just for pubsub.
When running locally with
gcloud authproviding application default credentials, pubsub is unable to infer a connection, so this will fail:with
EnvironmentError: Connection could not be inferred.The fix is to set an explicit connection using adc:
However, storage and datastore do not have this issue. It seems unnecessarily to do this just for pubsub.