Closed
Description
In which file did you encounter the issue?
Did you change the file? If so, how?
It's always best practice to declare the client only once in an application.
Change: Going to move line 49 outside the function at the global level.
Describe the issue
For every request, the client is getting instantiated therefore leaking the memory.
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'GET':
return render_template('index.html', messages=MESSAGES)
data = request.form.get('payload', 'Example payload').encode('utf-8')
# Consider initialzing the publisher client outside this function
# for low latency publish.
publisher = pubsub_v1.PublisherClient()