创建新 blob 时出现 GAE 错误(错误代码 104)

发布于 2024-12-02 15:19:45 字数 2837 浏览 1 评论 0原文

在 GAE 上,这行代码:

file_name = files.blobstore.create(mime_type='image/png')

会删除 google.appengine.runtime.DeadlineExceededError

以下是完整方法代码:

class UploadsHandler(JSONRequestHandler):
    def upload_blob(self, content, filename):
        file_name = files.blobstore.create(mime_type='image/png')

        file_str_list = split_len(content, 65520)

        with files.open(file_name, 'a') as f:
            for line in file_str_list:
                f.write(line)

        files.finalize(file_name)
        return files.blobstore.get_blob_key(file_name)

日志消息结尾为:

处理此请求的进程遇到严重问题,导致其退出。这可能会导致应用程序的下一个请求使用新的进程。如果您经常看到此消息,则可能是在应用程序初始化期间引发异常。 (错误代码 104

完整错误堆栈:

<class 'google.appengine.runtime.DeadlineExceededError'>: 
Traceback (most recent call last):
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 389, in main
    util.run_wsgi_app(application)
  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 116, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 339, in post
    original_key = "%s" % self.upload_blob(src)
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 268, in upload_blob
    file_name = files.blobstore.create(mime_type='image/png')
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 68, in create
    return files._create(_BLOBSTORE_FILESYSTEM, params=params)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 487, in _create
    _make_call('Create', request, response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 228, in _make_call
    rpc.wait()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 533, in wait
    self.__rpc.Wait()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 119, in Wait
    rpc_completed = self._WaitImpl()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/runtime/apiproxy.py", line 131, in _WaitImpl
    rpc_completed = _apphosting_runtime___python__apiproxy.Wait(self)

文件上传时创建 Blob。该应用程序的其他方法效果很好。看起来 blobstore 在 30 秒内没有响应。

有什么想法为什么会发生这种情况吗? 谢谢!

On GAE this line of code:

file_name = files.blobstore.create(mime_type='image/png')

drops google.appengine.runtime.DeadlineExceededError

Here is the full method code:

class UploadsHandler(JSONRequestHandler):
    def upload_blob(self, content, filename):
        file_name = files.blobstore.create(mime_type='image/png')

        file_str_list = split_len(content, 65520)

        with files.open(file_name, 'a') as f:
            for line in file_str_list:
                f.write(line)

        files.finalize(file_name)
        return files.blobstore.get_blob_key(file_name)

Logging message ends with:

A serious problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)

Full error stack:

<class 'google.appengine.runtime.DeadlineExceededError'>: 
Traceback (most recent call last):
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 389, in main
    util.run_wsgi_app(application)
  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 116, in run_bare_wsgi_app
    result = application(env, _start_response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 339, in post
    original_key = "%s" % self.upload_blob(src)
  File "/base/data/home/apps/s~mockup-cloud/1.352909931378411668/main.py", line 268, in upload_blob
    file_name = files.blobstore.create(mime_type='image/png')
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/blobstore.py", line 68, in create
    return files._create(_BLOBSTORE_FILESYSTEM, params=params)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 487, in _create
    _make_call('Create', request, response)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/files/file.py", line 228, in _make_call
    rpc.wait()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 533, in wait
    self.__rpc.Wait()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 119, in Wait
    rpc_completed = self._WaitImpl()
  File "/base/python_runtime/python_lib/versions/1/google/appengine/runtime/apiproxy.py", line 131, in _WaitImpl
    rpc_completed = _apphosting_runtime___python__apiproxy.Wait(self)

Blob is created while file upload. Other methods of the app work great. It looks like blobstore is not responding for under 30 sec.

Any ideas why this happens?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

述情 2024-12-09 15:19:45

看来您并不是唯一遇到此问题的人:

http:// /groups.google.com/group/google-appengine/browse_thread/thread/27e52484946cbdc1#

(今天发布)

Seems like you're not the only one having this issue:

http://groups.google.com/group/google-appengine/browse_thread/thread/27e52484946cbdc1#

(posted today)

冰雪梦之恋 2024-12-09 15:19:45

谷歌似乎对其服务器进行了一些重新配置。现在一切都像以前一样运行良好。

Seems like Google had some reconfigurations of their servers. Now everything's working fine as it was before.

软糯酥胸 2024-12-09 15:19:45

当您的请求处理程序执行时间过长时,就会发生 runtime.DeadlineExceededError - blobstore 调用恰好是发生这种情况时正在运行的内容。您需要使用 appstats 来分析您的处理程序,以了解它为何如此缓慢。

A runtime.DeadlineExceededError occurs when your request handler takes too long to execute - the blobstore call just happened to be what was running when that happened. You need to profile your handler with appstats to see why it's so slow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文