gpt4 book ai didi

python - Google App Engine - 使用任务队列或延迟作业

转载 作者:太空狗 更新时间:2023-10-30 00:37:21 25 4
gpt4 key购买 nike

Google App Engine 有两种稍后运行作业的方法,Task QueuesDeferred jops

据我所知,它们支持所有相同的功能(例如,延迟作业可以放在特定的任务队列中,这样您就可以限制执行)——但延迟作业看起来更容易实现,也更灵活。

有人知道每种方法的优缺点吗?在任何情况下您都希望对延迟作业使用任务队列?

最佳答案

我不确定你是否注意到了,但是 deferreds 的文档最后有这个部分:

You may be wondering when to use ext.deferred, and when to stick with the built-in task queue API. Here are our suggestions.

You may want to use the deferred library if:

  • You only use the task queue lightly.
  • You want to refactor existing code to run on the Task Queue with a minimum of changes.
  • You're writing a one off maintenance task, such as schema migration.
  • Your app has many different types of background task, and writing a separate handler for each would be burdensome.
  • Your task requires complex arguments that aren't easily serialized without using Pickle.
  • You are writing a library for other apps that needs to do background work.

You may want to use the Task Queue API if:

  • You need complete control over how tasks are queued and executed.
  • You need better queue management or monitoring than deferred provides.
  • You have high throughput, and overhead is important.
  • You are building larger abstractions and need direct control over tasks.
  • You like the webhook model better than the RPC model.

Naturally, you can use both the Task Queue API and the deferred library side-by-side, if your app has requirements that fit into both groups.

关于python - Google App Engine - 使用任务队列或延迟作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4909278/

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