首页 > 解决方案 > 多处理池挂起

问题描述

我创建了一个池来使用 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

等待您的帮助。

标签: pythonmultiprocessinggitpython

解决方案


好的,我找到了原因。这是因为我使用了一个gitpython库,它有时会挂起。


推荐阅读