Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Google Cloud SDK pub/sub sample memory leak #3259

Closed
@gaurgs

Description

@gaurgs

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/pubsub/main.py

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()

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions