【发布时间】:2015-03-14 14:30:15
【问题描述】:
首先,感谢您花时间回答这个问题。
我有一个设计问题(有点)。我有一组机器,用户可以在这些机器上执行任务。在机器上完成每个任务可能需要大约 5-20 分钟。任意数量的用户都可以执行任务 - 但是,他们可能并不关心他们的任务是否已排队并且不能立即执行。
作为一名软件开发人员,我想将我执行的任务数限制为每批 10 个,以防止终端系统崩溃。这就是我认为的方法:
a) Submit all jobs/tasks to a file.
b) Daemon wakes up every x minutes, checks if there is work to be performed.
b) Get 10 jobs that were submitted earliest and spawn processes to handle the tasks.
c) Daemon sleeps, wakes up again after x minutes and checks how many additional tasks can be performed (given that some of the 10 tasks may still be running), launches the corresponding tasks and goes back to sleep.
你们有什么建议或想法吗?
【问题讨论】:
-
如果计算机意外崩溃或断电,您不会丢失队列中的任务有多重要?
-
会很重要,因此文件
-
对如何处理当前“正在运行”的那些有什么想法吗?
标签: python architecture scripting software-design