当视图仍在运行时,Python django访问实时日志

时间:2019-03-01 07:23:20

标签: python django

如何在其他功能仍在运行时访问其生成的列表

def index(request):
  return render(request,"index.html")

def assigntoken(request):
   #I got list of users from post request to assign token to each of them I call a class called AssignToken
    v = AssignToken() 
    #AssignToken class has attribute called log_lst I want to be able to access this log_lst from result view while assigntoken view and class AssignToken still running 
    v.start(users)  #this will start loop in users list to assign tokens
    return redirect('/result')

def result(request):
    #while assigntoken function still running I should be able to access /result to see live logs generated in v.log_lst (AssignToken class object), how to do this?, is it safe to make it global variable, will it be unique for each user access the webapp at same time?
    context = {'logs':v.log_lst}
    return render(request,"results.html",context)

0 个答案:

没有答案