如何在python和google地图引擎上向线程模块发送一些数据
错误是:如何在python和google地图引擎上向线程模块发送一些数据,python,django,google-app-engine,multithreading,Python,Django,Google App Engine,Multithreading,错误是: from google.appengine.ext import db class Log(db.Model): content = db.StringProperty(multiline=True) class MyThread(threading.Thread): def run(self,request): #logs_query = Log.all().order('-date') #logs = logs_query.fetc
from google.appengine.ext import db
class Log(db.Model):
content = db.StringProperty(multiline=True)
class MyThread(threading.Thread):
def run(self,request):
#logs_query = Log.all().order('-date')
#logs = logs_query.fetch(3)
log=Log()
log.content=request.POST.get('content',None)
log.put()
def Log(request):
thr = MyThread()
thr.start(request)
return HttpResponse('')
当我不发送请求时
TypeError at /log
start() takes exactly 1 argument (2 given)
错误是:
class MyThread(threading.Thread):
def run(self):
log=Log()
log.content=request.POST.get('content',None)
log.put()
def Log(request):
thr = MyThread()
thr.start()
return HttpResponse('')
我不确定这是否能满足您的需求,甚至在谷歌appengine中也不可能,但是
如果您将
thr.start(request)
更改为thr.run(request)
错误应该消失您不能在App Engine上使用线程。注意:根据文档,Google不允许在其服务器中使用线程。
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\Python25\lib\threading.py", line 486, in __bootstrap_inner
self.run()
File "D:\zjm_code\helloworld\views.py", line 33, in run
log.content=request.POST.get('content',None)
NameError: global name 'request' is not defined