NotImplementedError: Only tempfile.TemporaryFile is available for use

NotImplementedError: Only tempfile.TemporaryFile is available for use

我正在使用 Django 和 Google App Engine。我无法确定错误从何而来,因为如果我在本地使用它,我的网站就可以正常运行。在我将它部署在 GAE 上后它工作正常但是当使用 googleadwords api 时出现这个错误:

NotImplementedError: Only tempfile.TemporaryFile is available for use
at PlaceHolder (/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_dist/lib/python2.7/tempfile.py:45)
at __init__ (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/suds/cache.py:115)
at __init__ (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/suds/client.py:112)
at GetService (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/googleads/adwords.py:459)
at post (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/ksvt/views.py:47)
at dispatch (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/views/generic/base.py:88)
at view (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/views/generic/base.py:68)
at _get_response (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/base.py:185)
at _get_response (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/base.py:187)
at inner (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/exception.py:41)

谁能解释一下这个错误是什么意思?谢谢!

编辑: 我认为产生错误的代码行。

 adwords_client = adwords.AdWordsClient.LoadFromStorage(os.path.dirname(os.path.abspath(__file__)) + "//googleads.yaml")

adwords 库正在使用 suds 将 SOAP 消息发送到 adwords API。 suds 包尝试在文件系统中缓存数据,这在 App Engine 标准环境中是被禁止的。

Adwords 包的 README 描述了如何通过将虚拟缓存实现传递给 adwords 客户端来禁用缓存:

adwords_client = adwords.AdWordsClient(
  developer_token, oauth2_client, user_agent,
  client_customer_id=client_customer_id, cache=suds.cache.NoCache())

(您需要导入 suds.cache