我用的是Python的多处理.Pool.map()对Jupyter笔记本中的一堆数据执行函数。我正在从池中获得正确和预期的结果,但是即使在我执行池.关闭(), 池.连接()和池.终止()我就是不明白为什么。在
下面是我创建池并对数据调用map()函数的代码片段:
for i in xrange(num_batches):
lw_range = int(i * self.batch_size)
up_range = int((i + 1) * self.batch_size)
# Put the remainder into the last batch
if remainder_size > 0 and i == (self.num_proc - 1):
up_range += int(remainder_size)
subset_df = self.tr_df[lw_range:up_range]
arg_list.append((subset_df, self.dates_v, self.sec_list, self.dict_mode, universe_m, speaker_type, section, \
corprep_type, aggregation))
sub_sent_matrices = mp_pool.map(_gen_sentiments_worker, arg_list)
print "Multiprocessing pool completed!...",
mp_pool.close()
mp_pool.join()
mp_pool.terminate()
下面是我用map()并行调用的函数。基本上,它实例化一个对象,该对象解析一些文本并以numpy数组/矩阵的形式返回结果:
^{pr2}$我不确定这是不是因为多处理.池()或者与Jupyter笔记本电脑发生了一些奇怪的冲突。以前有人遇到过这样的问题吗?在
谢谢!在
目前没有回答
相关问题 更多 >
编程相关推荐