如何用Django运行线程如何在视图文件中发送数据
from django.shortcuts import render
from django.http.response import HttpResponse
from datetime import datetime
from .pnet import Worker1
global value
value = False
def home(request):
global value
if value == False:
Worker1.start()
print(a)
value = True
today = datetime.today()
return render(request, "home.html")`
pnet.py
import threading
class Worker1(threading.Thread):
def run(self):
a = 10`
1条答案
按热度按时间k3bvogb11#