这是一个创建于 2533 天前的主题,其中的信息可能已经有所发展或是发生改变。
如下这是我写的方法。如何让用户想开启就开启?想关闭就会自动关闭所有正在执行的操作。
def monitor(request,url,enable=True):
if enable:
'''
执行 monitor 监控,创建一个线程来执行监控函数。。不停的监控。
'''
return HttpResponse("开启完成")
else:
'''
这里需要结束上面还在执行的线程该如果操作?
'''
return HttpResponse("关闭完成")
1 条回复 • 2017-10-24 14:09:06 +08:00
|
|
1
smgui 2017-10-24 14:09:06 +08:00
数据库或者 cache 里给任务做标记,线程执行的过程中读取标记。 如果标记为“关闭任务”则线程退出。
|