Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中设置多重报警_Python_Django_Multithreading_Celery - Fatal编程技术网

如何在python中设置多重报警

如何在python中设置多重报警,python,django,multithreading,celery,Python,Django,Multithreading,Celery,我想在python中设置多个报警。推荐的设置方式是什么?我的用例是为N变量设置阈值时间。当当前时间达到阈值时,我需要所有具有该阈值的变量 这是我的看法:- threshold_time_list = [get list all times from the DB] current_time = datetime.now() [i for i in threshold_time_list if i==current_time] 但这是一种非常低效的方法,因为我可能有250多个变量,比

我想在python中设置多个报警。推荐的设置方式是什么?我的用例是为
N
变量设置阈值时间。当当前时间达到阈值时,我需要所有具有该阈值的变量

这是我的看法:-

threshold_time_list = [get list all times from the DB]    

current_time = datetime.now()

[i for i in threshold_time_list if i==current_time]
但这是一种非常低效的方法,因为我可能有250多个变量,比如
a/b/c
。 我还必须每秒检查一次这种情况(cronjob)。有更好的方法吗

我发现在这样的情况下,可以使用线程并使线程在
threshold-current\u time
中休眠。但是并行运行250个线程又是一个问题,因为我在生产中遇到了一个问题,Django被挂起(不知道为什么),我需要重新启动服务器使其重新工作。我们假设Django可能无法处理线程,因此增加250个线程是很麻烦的

另外,如果有人知道,为什么Django会挂在运行的live产品的b/w上,这将是有益的

这个警报问题可以在芹菜中完成吗?

使用该模块。这允许您创建任意数量的计划任务,然后在开始时运行它们,一次一个