python - 多处理池挂起
问题描述
我创建了一个池来使用 Gitpython 进行 git clone。有一个大的 git repo 并且需要比其他人更多的时间来克隆。每个进程为一个 repo 做一个克隆工作。我Pool
使用如下:
multi_res = [p.apply_async(runfunc, args=(incl_info, project_root, skip_dirs,))
for incl_info in incl_infos]
LogInfo('Waiting for all subprocesses done...')
for i in range(len(incl_infos)):
while not multi_res[i].ready():
LogInfo("Downloading now")
time.sleep(5)
p.close()
p.join()
它在大多数情况下都能完美运行。但是会经常挂在最大的repo中。当我单独克隆回购时,它是有线的,它工作正常。所以我想知道 python 中是否有一些块multiprocessing.Pool
。
我已经 strace 挂起的 git clone 进程。git进程输出如下:
Process 27649 attached
read(6, 0x7ffc36dae050, 4) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=2895997, ptr=0x2c307d}} ---
rt_sigreturn() = 0
read(6, 0x7ffc36dae050, 4) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=2895997, ptr=0x2c307d}} ---
rt_sigreturn() = 0
read(6, 0x7ffc36dae050, 4) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=2895997, ptr=0x2c307d}} ---
rt_sigreturn() = 0
read(6, 0x7ffc36dae050, 4) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGALRM {si_signo=SIGALRM, si_code=SI_KERNEL, si_value={int=2895997, ptr=0x2c307d}} ---
rt_sigreturn() = 0
git-lfs 输出如下:
Process 28006 attached
[ Process PID=28006 runs in 32 bit mode. ]
futex(0x88b982c, FUTEX_WAIT_PRIVATE, 0, NULL
等待您的帮助。
解决方案
好的,我找到了原因。这是因为我使用了一个gitpython
库,它有时会挂起。
推荐阅读
- node.js - 如何使用带有回调函数的异步等待
- php - 我无法使用 password_hash 登录
- tensorflow-lite - 将保存的模型转换为 tflite - 'image_tensor' 的形状无效 '[None, None, None, 3]'
- php - 如何将字符作为表达式的结尾
- c++ - 通过线程共享指针的 std::vector
- python - AttributeError:类型对象“UserProfile”没有属性“USERNAME_FIELD”
- python - 用于 lambda 演算的 Python 解析器
- c++ - 无法访问派生类中的基本受保护成员!(在虚函数中)
- javascript - Select2 和 Datetimepicker 在克隆的 div 中不起作用
- c - 在C中使用空格将char转换为int