如何在谷歌应用程序引擎中将后台任务带到前台?

发布于 2024-10-06 08:03:04 字数 112 浏览 2 评论 0原文

目前我有任务在后台运行。任务执行完成后,我需要显示输出。如何在 Google App Engine 中执行此操作?

任务完成后,我唯一能做的就是创建另一个应该显示输出的任务,或者还有其他方法吗?

Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine?

Once the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝戈者 2024-10-13 08:03:04

你不能“将任务带到前台”——它是一个网络服务器。服务器响应来自客户端的请求。

但是,您有多种选择可以完成类似的任务:

  1. 使用Channel API向客户发送工作已完成的通知,甚至是处理结果。
  2. 将状态信息写入 memcache数据存储区 并从客户端进行轮询以确定工作何时完成。

You can't "bring a task to the foreground" -- it is a webserver. The server responds to requests from the client.

But, you have a couple choices to accomplish something similar:

  1. Use the Channel API to send the client notice that the work is finished, or a even the results of the processing.
  2. Write status info to memcache or the datastore and poll from the client to determine when the work is finished.
始终不够爱げ你 2024-10-13 08:03:04

这不会像您所描述的那样直接起作用。

一旦后台任务启动,它就一直是后台任务。如果您想从后台任务返回一些信息给用户,您必须将其添加到数据存储中,并让前台处理程序检查数据存储中的该信息。

您也许还可以使用 Channel API 让后台任务直接向浏览器发送消息,但我不确定这是否有效(我还没有尝试过)。

如果您提供更多有关您想要完成的任务的更多信息,我可以尝试提供有关如何完成它的更多详细信息。

This won't work directly as you describe it.

Once a background task is started, it's a background task for its entire existence. If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information.

You may also be able to use the Channel API to have a background task send messages directly to the browser, but I'm not sure if this will work or not (I haven't tried it).

If you give a little more information about exactly what you're trying to accomplish I can try to give more details about how to get it done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文