从locale dev安装程序运行应用程序时,我的预热请求处理程序被多次调用

2024-09-20 22:03:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我在我的googleappengine项目中有一个预热请求。但是,在本地dev服务器上进行测试时,会多次调用处理程序

在app.yaml文件中正确配置:

- url: /_ah/warmup
  script: main.app
  login: admin

inbound_services:
  - warmup

我只是不明白为什么它被多次调用。这是与本地开发设置有关还是我做错了什么

这里是主要的.py减去进口

class WarmUpRequestsHandler(webapp2.RequestHandler):
    """
    Warmup requests pre gae instance loading
    """

    def get(self):
        from google.appengine.api import memcache
        from product.lib.lib import ProductCaches

        logging.info('warmup request handler')

        kwargs = {
            'klass': TheLatest(),
            'products_qry': 'EMA',
            'product_entity': 'ema_latest',
            'memcache_key': 'ema-latest',
        }

        entity = ProductCaches(**kwargs)
        entity.get_and_set()
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Warmup successful')


webapp2_config = config.config

app = webapp2.WSGIApplication([("/_ah/warmup", WarmUpRequestsHandler)],debug = os.environ['SERVER_SOFTWARE'].startswith('Dev'), config=webapp2_config)
# Import All Routes

adminroutes.add_routes(app)
authroutes.add_routes(app)
emailroutes.add_routes(app)
hotroutes.add_routes(app)
mediaroutes.add_routes(app)
messageroutes.add_routes(app)
paymentroutes.add_routes(app)
productroutes.add_routes(app)
searchroutes.add_routes(app)
storeroutes.add_routes(app)
routes.add_routes(app)

Tags: fromimportselfaddconfigappgetmemcache

热门问题