【问题标题】:FileNotOpenedError with Cloud storage on GAEGAE 上云存储的 FileNotOpenedError
【发布时间】:2012-07-15 21:19:14
【问题描述】:

我正在尝试从远程 api shell 写入云存储中的文件并看到以下内容:

s~appid> FILENAME = '/gs/test_bucket/test'

s~appid> writable_file = files.gs.create(FILENAME,
mime_type='application/octet-stream', acl='project-private')

s~appid> with files.open(writable_file, 'a') as f:
          ...     f.write('[]')
          ...
---------------------------------------------------------------------------
FileNotOpenedError                        Traceback (most recent call last)
/Users/dhruvkaranmehta/Projects/getaround3/tools/g3/shell.pyc in <module>()
      1 with files.open(writable_file, 'a') as f:
----> 2     f.write('[]')
      3

/usr/local/google_appengine/google/appengine/api/files/file.pyc in
__exit__(self, atype, value, traceback)
    288
    289   def __exit__(self, atype, value, traceback):
--> 290     self.close()
    291
    292   def write(self, data, sequence_key=None):

/usr/local/google_appengine/google/appengine/api/files/file.pyc in
close(self, finalize)
    282     request.set_filename(self._filename)
    283     request.set_finalize(finalize)
--> 284     self._make_rpc_call_with_retry('Close', request, response)
    285
    286   def __enter__(self):

/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_rpc_call_with_retry(self, method, request, response)
    395   def _make_rpc_call_with_retry(self, method, request, response):
    396     try:
--> 397       _make_call(method, request, response)
    398     except (ApiTemporaryUnavailableError,
FileTemporaryUnavailableError):
    399

/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_make_call(method, request, response, deadline)
    243     rpc.check_success()
    244   except apiproxy_errors.ApplicationError, e:
--> 245     _raise_app_error(e)
    246
    247

/usr/local/google_appengine/google/appengine/api/files/file.pyc in
_raise_app_error(e)
    186   elif (e.application_error ==
    187         file_service_pb.FileServiceErrors.FILE_NOT_OPENED):
--> 188     raise FileNotOpenedError()
    189   elif (e.application_error ==
    190         file_service_pb.FileServiceErrors.READ_ONLY):

FileNotOpenedError:

这看起来很奇怪,因为文件刚刚打开。我还看到了另一种情况,在“a”模式下打开文件会导致FinalizationError

任何其他信息都会非常有帮助。

谢谢!

【问题讨论】:

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


    【解决方案1】:

    对于第一部分,有一个功能请求来支持来自远程 api shell 的文件 api。您能否使用交互式控制台尝试相同的操作(请参阅Is there an interactive console for public/uploaded app engine apps?)。

    关于您的第二个错误,documentation 声明:

    您无法打开和写入已完成的文件。

    【讨论】:

    • 关于远程 api shell 的部分结果是真实的。但是手头的问题最终是 acl 被设置为 public-read-write(我在帖子中手动擦洗了它) . acl 恰好会影响获得文件排他锁的能力。如果您最终遇到 ExclusiveLockFailedError,请尝试更改 acl。
    猜你喜欢
    • 1970-01-01
    • 2012-10-15
    • 2015-05-19
    • 2015-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多