def _execute_models(self, gmnn_queue=[], is_gm11=False):
if self._is_empty(gmnn_queue):
return []
pool = mp.Pool()
cpu_count = self.cpu_count
length = len(gmnn_queue)
block_count = long(math.ceil(length / float(cpu_count)))
start_index = 0
end_length = cpu_count
for block in xrange(0, block_count):
for gm_model in gmnn_queue[start_index:end_length]:
if is_gm11 == False:
pool.apply_async(gm_model.analyze())
else:
pool.apply_async(gm_model.forecast())
start_index += cpu_count
end_length += cpu_count
if end_length > length:
end_length = length
self._close_pool(pool)
return gmnn_queue
评论列表
文章目录