【问题标题】:GAE tasks that runs for one hour?运行一小时的 GAE 任务?
【发布时间】:2016-04-25 19:37:26
【问题描述】:

在按照 Google App Engine 的指南配置我的任务时,我读到可以有一些 tasks runs for more than 10 minutes(默认限制)并通过使用手动或基本扩展模块达到一小时。

我尝试以这种方式配置它(使用以下 yaml 配置),但我的任务总是在 10 分钟后被终止,而不是 1 小时。

我做错了什么?

queue.yaml:

queue:
 - name: long_process
   max_concurrent_requests: 10
   rate: 1/s

... (other tasks)

long_process_queue_module.yaml:

module: long-process-queue-module
runtime: python27
api_version: 1
version: 1
threadsafe: true

instance_class: B1
manual_scaling:
  instances: 5

handlers:
- url: /_ah/queue/myhandler
  script: wsgi.application
  login: admin

怎么了?如何将持续时间设置为 1 小时?

如果它很重要,我还希望能够同时运行多个任务。我目前设置instances: 5 怀疑它会同时运行5个长进程,但也许我在这里也错了?

【问题讨论】:

  • 任务在基本或手动扩展实例中可以运行多长时间没有限制。如有必要,它可以运行数天。一个实例可以关闭,但如果它保持运行,它可以无限期地继续运行您的任务。
  • 这是真的吗?我知道后台线程的最大生命周期为 24 小时,但不确定任务。

标签: python google-app-engine task


【解决方案1】:

需要在long-process-queue-module中定义要运行的任务,可以在queue.yaml中指定目标字段,或者入队任务时。 https://cloud.google.com/appengine/docs/python/config/queue#target https://cloud.google.com/appengine/docs/python/taskqueue/tasks#task_target

【讨论】:

  • 你能告诉我GAE将如何处理多个并发进程吗?是否有规则说“同时只运行 X 进程,然后将另一个排队”?是max_concurrent_requests 吗?提前致谢。
  • 是的,您可以通过队列参数中的max_concurrent_requests 进行控制。 app.yaml 中还有另一个max_concurrent_requests 用于控制每个实例的线程。
  • 我实现了您的答案,并且成功了。我接受了你的回答。谢谢
猜你喜欢
  • 2011-07-28
  • 2018-01-13
  • 2020-10-23
  • 2010-10-05
  • 1970-01-01
  • 2018-08-13
  • 1970-01-01
  • 2014-09-17
  • 2020-10-12
相关资源
最近更新 更多