简体   繁体   中英

NotImplementedError: Only tempfile.TemporaryFile is available for use

I'm using django and Google App Engine. I can't determine where's the error came from because if I'm using it on local my site is functioning. After I deployed it on GAE it works fine but when using googleadwords api this error comes:

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)

Can someone explain what is the meaning of this error? Thanks!

Edit: The line of code that I think generates the error.

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

The adwords library is using suds to send SOAP messages to the adwords API. The suds package tries to cache data in the filesystem, which is forbidden in the App Engine standard environment.

The Adwords package's README describes how to disable caching by passing the a dummy cache implementation to the adwords client:

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

(You will need to import suds.cache )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM