我在Google的一个git仓库中发现了一些关于bigquery插入的示例代码。应用程序引擎上线程安全的客户端库(python)
如果你看到的app.yaml它说这个代码应该是线程安全的,但如果我在客户端的lib的文档(https://developers.google.com/api-client-library/python/guide/thread_safety)lokking它不应该是线程安全的。我现在有点困惑,我的下面的代码是线程安全的还是不是? 它运行在应用程序引擎标准环境中。
import pprint
from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
# Create the bigquery api client
service = build('bigquery', 'v2', credentials=credentials)
response = service.datasets().list(projectId='PROJECTID').execute()
pprint.pprint(response)
---- ----更新添 的回答后,我改变了我的代码如下。这个现在应该是好的:
import pprint
from googleapiclient.discovery import build
from oauth2client.contrib.appengine import AppAssertionCredentials
import httplib2
credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/bigquery')
# Create the bigquery api client
service = build('bigquery', 'v2')
def get():
# authorize http object with client credentials
http = credentials.authorize(httplib2.Http())
response = service.datasets().list(projectId='PROJECTID').execute(http=http)
pprint.pprint(response)
请你看看更新吗?谢谢 –