App Engine:API 调用 file.Create() 响应时间过长,已被取消
当我尝试使用文档(如下)中提供的相同示例写入 blobstore 时,它每次都能在开发服务器上运行,但在 appspot 上 100% 失败,并出现以下错误:The API call file.Create( )响应时间过长,被取消。
谷歌搜索显示,这是一个罕见的问题,尽管有些人已经报告过该问题。知道这是怎么回事吗?
我在开发服务器上使用Python 2.6,所以这也许是我在开发过程中没有看到这个的原因。
from __future__ import with_statement
from google.appengine.api import files
# Create the file
file_name = files.blobstore.create(mime_type='application/octet-stream')
# Open the file and write to it
with files.open(file_name, 'a') as f:
f.write('data')
# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)
# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)
回溯:
The API call file.Create() took too long to respond and was cancelled.
Traceback (most recent call last):
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1516, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1510, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1258, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1082, in __call__
return handler.dispatch()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 552, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 550, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 43, in get
file_name = files.blobstore.create(mime_type='text/html')
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 69, in create
return files._create(_BLOBSTORE_FILESYSTEM, params=params)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 491, in _create
_make_call('Create', request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 234, in _make_call
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 558, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
DeadlineExceededError: The API call file.Create() took too long to respond and was cancelled.
Saved; key: __appstats__:082400, part: 41 bytes, full: 5691 bytes, overhead: 0.000 + 0.004; link: http://czongae.appspot.com/_ah/stats/details?time=1328696282404
<class 'google.appengine.runtime.apiproxy_errors.DeadlineExceededError'>: The API call file.Create() took too long to respond and was cancelled.
Traceback (most recent call last):
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 72, in <module>
main()
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 69, in main
app.run()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1595, in run
_webapp_util.run_wsgi_app(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 118, in run_bare_wsgi_app
for data in result:
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/recording.py", line 924, in appstats_wsgi_wrapper
result = app(environ, appstats_start_response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1524, in __call__
response = self._internal_error(e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1516, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1510, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1258, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1082, in __call__
return handler.dispatch()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 552, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 550, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 43, in get
file_name = files.blobstore.create(mime_type='text/html')
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 69, in create
return files._create(_BLOBSTORE_FILESYSTEM, params=params)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 491, in _create
_make_call('Create', request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 234, in _make_call
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 558, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
When I try to write to blobstore using the same example provided in the docs (below), it works every time on dev server, but fails 100% of the time on appspot with this error: The API call file.Create() took too long to respond and was cancelled.
Googling show that this is a rare issue although some have reported it. Any idea what's going on here?
I'm using Python 2.6 on dev server so that maybe why I'm not seeing this during dev.
from __future__ import with_statement
from google.appengine.api import files
# Create the file
file_name = files.blobstore.create(mime_type='application/octet-stream')
# Open the file and write to it
with files.open(file_name, 'a') as f:
f.write('data')
# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)
# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)
Traceback:
The API call file.Create() took too long to respond and was cancelled.
Traceback (most recent call last):
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1516, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1510, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1258, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1082, in __call__
return handler.dispatch()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 552, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 550, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 43, in get
file_name = files.blobstore.create(mime_type='text/html')
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 69, in create
return files._create(_BLOBSTORE_FILESYSTEM, params=params)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 491, in _create
_make_call('Create', request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 234, in _make_call
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 558, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
DeadlineExceededError: The API call file.Create() took too long to respond and was cancelled.
Saved; key: __appstats__:082400, part: 41 bytes, full: 5691 bytes, overhead: 0.000 + 0.004; link: http://czongae.appspot.com/_ah/stats/details?time=1328696282404
<class 'google.appengine.runtime.apiproxy_errors.DeadlineExceededError'>: The API call file.Create() took too long to respond and was cancelled.
Traceback (most recent call last):
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 72, in <module>
main()
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 69, in main
app.run()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1595, in run
_webapp_util.run_wsgi_app(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/util.py", line 118, in run_bare_wsgi_app
for data in result:
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/recording.py", line 924, in appstats_wsgi_wrapper
result = app(environ, appstats_start_response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1524, in __call__
response = self._internal_error(e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1516, in __call__
rv = self.handle_exception(request, response, e)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1510, in __call__
rv = self.router.dispatch(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1258, in default_dispatcher
return route.handler_adapter(request, response)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 1082, in __call__
return handler.dispatch()
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 552, in dispatch
return self.handle_exception(e, self.app.debug)
File "/base/data/home/apps/s~czongae/1.356669185377832769/webapp2.py", line 550, in dispatch
return method(*args, **kwargs)
File "/base/data/home/apps/s~czongae/1.356669185377832769/main.py", line 43, in get
file_name = files.blobstore.create(mime_type='text/html')
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 69, in create
return files._create(_BLOBSTORE_FILESYSTEM, params=params)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 491, in _create
_make_call('Create', request, response)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 234, in _make_call
rpc.check_success()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 558, in check_success
self.__rpc.CheckSuccess()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 133, in CheckSuccess
raise self.exception
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它没有记录在官方手册中。但在打开文件时尝试添加
exclusive_lock=True
。在我的 blobstore 从 M/S 迁移到 HRD 期间,我想我遇到了这个问题。http:// /code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/files/file.py#402
It's not documented to the official manual. but try to add
exclusive_lock=True
when you open the file. During the migration of my blobstore from M/S to HRD I think I had this problem.http://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/api/files/file.py#402