Skip to content

Commit

Permalink
Generate datastore grpc client outside request handler
Browse files Browse the repository at this point in the history
Generating a datastore grpc client for each request is not required and can lead to auth issues.
Here is one of the auth issues in question: googleapis/google-cloud-python#3085

Also note the following issue which is causing the client to need resetting every 30 mins: googleapis/google-cloud-python#2896. This will hopefully be fixed soon.
  • Loading branch information
cobookman authored Mar 10, 2017
1 parent 1af1c30 commit 16bd830
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions appengine/flexible/datastore/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


app = Flask(__name__)

ds = datastore.Client()

def is_ipv6(addr):
"""Checks if a given address is an IPv6 address."""
Expand All @@ -35,8 +35,6 @@ def is_ipv6(addr):
# [START example]
@app.route('/')
def index():
ds = datastore.Client()

user_ip = request.remote_addr

# Keep only the first two octets of the IP address.
Expand Down

0 comments on commit 16bd830

Please sign in to comment.