【问题标题】:os.pipe() function in google app engine谷歌应用引擎中的 os.pipe() 函数
【发布时间】:2014-12-16 09:48:11
【问题描述】:

我目前正在尝试在谷歌应用引擎上使用 python 压缩一个大文件 (> 1GB),由于谷歌应用引擎对进程的内存缓存的限制,我使用了以下解决方案。 Create a zip file from a generator in Python?

当我在应用引擎上运行代码时,出现以下错误

Traceback (most recent call last):
  File "/base/data/home/apps/s~whohasfiles/frontend.379535120592235032/gluon/restricted.py", line 212, in restricted
    exec ccode in environment
  File "/base/data/home/apps/s~whohasfiles/frontend.379535120592235032/applications/onefile/controllers/page.py", line 742, in <module>
  File "/base/data/home/apps/s~whohasfiles/frontend.379535120592235032/gluon/globals.py", line 194, in <lambda>
    self._caller = lambda f: f()
  File "/base/data/home/apps/s~whohasfiles/frontend.379535120592235032/applications/onefile/controllers/page.py", line 673, in download
    zip_response = page_store.gcs_zip_page(page, visitor)
  File "applications/onefile/modules/page_store.py", line 339, in gcs_zip_page
    w = z.start_entry(ZipInfo('%s-%s' %(file.created_on, file.name) ))
  File "applications/onefile/modules/page_store.py", line 481, in start_entry
    r, w = os.pipe()
OSError: [Errno 38] Function not implemented

google 应用引擎不支持 OS.pipe() 函数吗? 请问我该如何解决?

【问题讨论】:

    标签: python google-app-engine python-2.7 google-cloud-storage


    【解决方案1】:

    “os”模块可用,但禁用了不受支持的功能,例如 pipe(),因为它对文件对象 [1] 进行操作。您需要使用 Google Cloud Storage 存储桶作为临时对象,因为不存在可用于 App Engine 运行时本地存储的文件对象的概念。 GCS 客户端库将为您提供对可用于此目的的存储桶的类似文件的访问权限 [2]。每个应用都可以访问默认存储桶,您可能需要先激活该存储桶 [3]。

    [1]https://cloud.google.com/appengine/docs/python/#Python_Pure_Python
    [2]https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/
    [3]https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/activate

    【讨论】:

      猜你喜欢
      • 2011-05-06
      • 1970-01-01
      • 2011-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多