gpt4 book ai didi

google-app-engine - devappserver2、remote_api 和 --default_partition

转载 作者:太空宇宙 更新时间:2023-11-03 15:29:59 25 4
gpt4 key购买 nike

要使用原始的 dev_appserver 在本地访问远程数据存储,我会设置 --default_partition=s,如前所述 here

2013 年 3 月,Google 将 devappserver2 设为默认开发服务器,但它不支持 --default_partition 导致原来的,可怕的:

BadRequestError: app s~appname cannot access app dev~appname's data

似乎前几个请求已正确处理

os.environ["APPLICATION_ID"] == 's~appname'

随后的请求导致调用/_ah/warmup 然后

os.environ["APPLICATION_ID"] == 'dev~appname'

文档特别提到了相关主题,但似乎是针对 dev_appserver here

Warning! Do not get the App ID from the environment variable. The development server simulates the production App Engine service. One way in which it does this is to prepend a string (dev~) to the APPLICATION_ID environment variable, which is similar to the string prepended in production for applications using the High Replication Datastore. You can modify this behavior with the --default_partition flag, choosing a value of "" to match the master-slave option in production. Google recommends always getting the application ID using the get_application_id() method, and never using the APPLICATION_ID environment variable.

最佳答案

你可以做以下肮脏的小把戏:

from google.appengine.datastore.entity_pb import Reference

DEV = os.environ['SERVER_SOFTWARE'].startswith('Development')

def myApp(*args):
return os.environ['APPLICATION_ID'].replace("dev~", "s~")

if DEV:
Reference.app = myApp

关于google-app-engine - devappserver2、remote_api 和 --default_partition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16287790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com