3

I have a simple service that publishes messages to a PubSub topic and occasionally get a "Deadline Exceeded" error message:

GaxError(RPC failed, caused by <_Rendezvous of RPC that terminated with (StatusCode.DEADLINE_EXCEEDED, Deadline Exceeded)>)

Python code:

from google.cloud import pubsub
pubsub_client = pubsub.Client()
topic = pubsub_client.topic("pubsub-topic")
data = data.encode('utf-8')
message_id = topic.publish(data)

It posts a few messages a second, from a Flask web app, and maybe one in a few hundred fail with that error.

1 Answer 1

2

Turns out I was creating too many PubSub clients!

I moved this part outside the function / route so that the topic and client are global variables and aren't initialized with each call:

pubsub_client = pubsub.Client()
topic = pubsub_client.topic("pubsub-topic")

(Right after instantiating Flask):

app = Flask(__name__)
1
  • 1
    What is Flask? I am also facing same issue Commented Dec 24, 2017 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.