【发布时间】:2010-04-24 01:52:30
【问题描述】:
此代码能否在 Google App Engine 中创建线程。如果没有,为什么不呢? 类 LogText(db.Model): 内容 = db.StringProperty(multiline=True)
class MyThread(threading.Thread):
def __init__(self,threadname):
threading.Thread.__init__(self, name=threadname)
def run(self,request):
log=LogText()
log.content=request.POST.get('content',None)
log.put()
def Log(request):
thr = MyThread('haha')
thr.run(request)
return HttpResponse('')
【问题讨论】:
-
不确定您使用的是哪个 Python 版本,但这不会与 Python 2.7 和 3.x 并行运行——您会阻止
thr.run(request。相反,您应该使用t.start()启动一个线程。
标签: python multithreading google-app-engine