如何使一个线程永不停止,每10秒向数据库写入一些内容

2024-04-16 20:11:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我用gae和django

这是我的密码:

class LogText(db.Model):
    content = 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('')

Tags: runselflogdbinitrequestdefcontent