GoogleCloudPlatform / GoogleCloudPlatform/appengine-python-standard

AttributeError: 'DefaultApiStub' object has no attribute 'CancelApiCalls'

未关闭
#120 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
86
派生
61
PR 合并指标
30 天内没有已合并 PR

描述

## Expected Behavior

Upgrading from Python2 to Python3, I expected the following piece of code to continue working with this library.

```
try:
from google.appengine.api import runtime, apiproxy_stub_map

def hook():
logging.info("Instance is shutting down; cleaning up.")

apiproxy_stub_map.apiproxy.CancelApiCalls()

runtime.set_shutdown_hook(hook)
except ImportError:
pass
```

Is this deprecated? If yes, then should it be replaced with something else or is this functionality not needed any more? I can see the method somewhere in the library source code, but AppEngine seems not recognizing it?

## Actual Behavior

```
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 140, in ErrorLoggingMiddleware
return app(wsgi_env, start_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 82, in
lambda app: lambda wsgi_env, start_resp: f(app, wsgi_env, start_resp),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/google/appengine/runtime/middlewares.py", line 375, in BackgroundAndShutdownMiddleware
runtime.__BeginShutdown()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/google/appengine/api/runtime/runtime.py", line 122, in __BeginShutdown
shutdown_hook()
File "/workspace/components/campaigns/push/processor/apns/send.py", line 40, in hook
apiproxy_stub_map.apiproxy.CancelApiCalls()
File "/layers/google.python.pip/pip/lib/python3.12/site-packages/google/appengine/api/apiproxy_stub_map.py", line 375, in CancelApiCalls
self.__default_stub.CancelApiCalls()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DefaultApiStub' object has no attribute 'CancelApiCalls'
```

## Steps to Reproduce the Problem

1. Install the shutdown hook
```
try:
from google.appengine.api import runtime, apiproxy_stub_map

def hook():
logging.info("Instance is shutting down; cleaning up.")

apiproxy_stub_map.apiproxy.CancelApiCalls()

runtime.set_shutdown_hook(hook)
except ImportError:
pass
```

2. Use the app engine service and wait for it to stop.

## Specifications

- Version: 1.1.6
- Platform: Google Appengine
- Python3.12

贡献指南

打开贡献指南

调研方向

Start with google/appengine/api/apiproxy_stub_map.py and google/appengine/api/runtime/runtime.py, following the shutdown hook into DefaultApiStub.CancelApiCalls. Reproduce the failure on Python 3.12 with the provided hook and inspect how the default stub is initialized. Done means the shutdown path no longer raises this AttributeError, or the supported replacement and required documentation are identified with regression coverage.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend, cloud
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。