我可以用Python在appenging中创建线程吗?

2024-09-30 05:32:37 发布

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

这段代码可以在googleappengine中创建线程吗。如果没有,为什么不呢? 类LogText(数据库模型): 内容=数据库StringProperty(多行=真)

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: run代码selflog数据库initrequestdef
1条回答
网友
1楼 · 发布于 2024-09-30 05:32:37

appengine不允许您创建新线程,这可能是因为appengine的主要目标是构建简单的请求-响应应用程序,而线程通常不被认为是“简单的”。在

管理应用程序的线程以防止滥用(意外或其他)对appengine来说是困难的,或者不可能做到的,所以他们完全不允许这样做。在

相关问题 更多 >

    热门问题