We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a9946c2 commit efe5e78Copy full SHA for efe5e78
appengine/flexible/pubsub/main.py
@@ -35,6 +35,9 @@
35
# Global list to storage messages received by this instance.
36
MESSAGES = []
37
38
+# Initialize the publisher client once to avoid memory leak
39
+# and reduce publish latency.
40
+publisher = pubsub_v1.PublisherClient()
41
42
# [START gae_flex_pubsub_index]
43
@app.route('/', methods=['GET', 'POST'])
@@ -44,9 +47,7 @@ def index():
44
47
45
48
data = request.form.get('payload', 'Example payload').encode('utf-8')
46
49
- # Consider initialzing the publisher client outside this function
- # for low latency publish.
- publisher = pubsub_v1.PublisherClient()
50
+ # publisher = pubsub_v1.PublisherClient()
51
topic_path = publisher.topic_path(
52
current_app.config['PROJECT'],
53
current_app.config['PUBSUB_TOPIC'])
0 commit comments