Skip to content

Commit

Permalink
win下如果只开一个进程,那么只在主进程里运行,方便pdb debug且与joblib运行方式保持一致
Browse files Browse the repository at this point in the history
  • Loading branch information
bbfamily committed Sep 1, 2017
1 parent 37a5591 commit ab769f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions abupy/CoreBu/ABuParallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ def when_done(r):
# 主要为了适配 n_jobs = -1,joblib中启动cpu个数个进程并行执行
self.n_jobs = ABuEnv.g_cpu_cnt

with ProcessPoolExecutor(max_workers=self.n_jobs) as pool:
if self.n_jobs == 1:
# 如果只开一个进程,那么只在主进程里运行,方便pdb debug且与joblib运行方式保持一致
for jb in iterable:
# 这里iterable里每一个元素是delayed.delayed_function保留的tuple
future_result = pool.submit(jb[0], *jb[1], **jb[2])
future_result.add_done_callback(when_done)
result.append(jb[0](*jb[1], **jb[2]))
else:
with ProcessPoolExecutor(max_workers=self.n_jobs) as pool:
for jb in iterable:
# 这里iterable里每一个元素是delayed.delayed_function保留的tuple
future_result = pool.submit(jb[0], *jb[1], **jb[2])
future_result.add_done_callback(when_done)
return result


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"使用load_abu_result_tuple读取上一节保存在本地的训练集数据:"
"在运行完成第15节中相关内容后,使用load_abu_result_tuple读取上一节保存在本地的训练集数据:"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"使用load_abu_result_tuple读取第15节中保存在本地的训练集数据:"
"在运行完成第15节中相关内容后,使用load_abu_result_tuple读取第15节中保存在本地的训练集数据:"
]
},
{
Expand Down

0 comments on commit ab769f7

Please sign in to comment.