我是一个真正的编码n00b,如果这是一个简单或基本的问题,请道歉.
我正在编写Python,Webapp,Appengine.
我的问题是,在我写完页面之后是否可以继续工作?那是最好的办法吗?基本上,当有人在我的网站上创建一个列表(www.7bks.com)时,我想继续工作,对他们刚刚选择的书籍进行一些’后处理’.
目前我有类似的东西(伪代码!)
class InputList(webapp.RequestHandler):
def post(self):
#get books data from the post and put in datastore
list = List()
list = self.request.get('books')
list.put()
#redirect the user to the new list
self.redirect("http://www.7bks.com/list/&s" % list.id)
现在,我想对列表中的每本书做一些缓慢的(涉及API调用)后期处理.我不想减慢重定向用户和生成列表页面的速度,因为我的后处理不会直接影响列表页面.我可以这样做吗?
class InputList(webapp.RequestHandler):
def post(self):
#get books data from the post and put in datastore
list = List()
list = self.request.get('books')
list.put()
#redirect the user to the new list
self.redirect("http://www.7bks.com/list/&s" % list.id)
#carry on working behind the scenes independently of the user
for book in list:
data = heavyprocessing(book)
这会导致我的应用程序有效地提供重定向,然后继续在幕后工作吗?
有更好的方法吗?我知道我可以使用CRON,但是在创建列表后我很快就会喜欢这个繁重的处理数据,但不是立即.像Cron这样的感觉可能不是正确的答案(除非我每分钟都要运行一个CRON脚本并检查要处理的新书吗?)
我知道这不是我的问题,但是我想不出一个好的方式来表达它.我确定这种事情有一些标准的术语,但我不知道它是什么.谢谢 :)
汤姆