Skip to main content
 首页 » 编程设计

python之Google App Engine queue.yaml 在开发服务器中不工作

2025年02月15日20落叶无声

我无法让 dev_appserver.py 识别我使用 queue.yaml 创建的自定义队列。它们没有出现在 http://localhost:8000/taskqueue 中,当我尝试向它们添加任务时,我得到 UnknownQueueError。它在生产环境中运行良好。

我在 Windows 10 上使用 python 2.7。

队列.yaml

total_storage_limit: 5G 
queue: 
- name: not-queue-a 
  bucket_size: 500 
  rate: 10/s 
  retry_parameters: 
  task_retry_limit: 2 
  min_backoff_seconds: 10 
  target: msnot 
- name: ui-worker 
  target: msbui 
  bucket_size: 200 
  rate: 1/s 
  retry_parameters: 
  task_retry_limit: 4 
  min_backoff_seconds: 1 

我的项目结构是这样的:

    |-- root 
        |-- queue.yaml 
        |-- index.yaml 
        |-- dispatch.yaml 
        |-- cron.yaml 
        |-- microservice1 
            |-- app.yaml 
            |-- microservice1.py 
        |-- microservice2 
            |-- app.yaml 
            |-- microservice1.py 
        |-- microservice3 
            |-- app.yaml 
            |-- microservice3.py 
        |-- microservice4 
            |-- app.yaml 
            |-- microservice4.py 

我尝试将 queue.yaml 的副本添加到微服务子文件夹,但我仍然遇到同样的问题。我也重启了 dev_appserver.py 几次。

请您参考如下方法:

当我将我的应用程序拆分为多个服务时,我遇到了同样的问题,dev_appserver.py 没有完全 catch 多服务应用程序。我通过符号链接(symbolic link)每个服务中的 queue.yaml 文件解决了这个问题:

    |-- microservice1 
        |-- app.yaml             
        |-- microservice1.py 
        |-- queue.yaml -> ../queue.yaml 

可能只有 default 服务需要它,但我对此并不完全确定,我没有尝试过。

注意:我对其他应用级配置文件应用了类似的方法。另见 Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?