pypa/pipx

parallel execution of pipx

已关闭

#1,056 创建于 2023年9月13日

 (2 条评论) (4 个反应) (0 位负责人)Python (592 个派生)batch import
enhancementhelp wanted

仓库指标

星标
 (12,938 个星标)
PR 合并指标
 (平均合并 4天 12小时) (30 天内合并 22 个 PR)

描述

Not sure if this is a bug or a feature request, I just wanted to note this here since I haven't seen a pertaining issue.

Describe the bug Executing pipx commands in parallel can result in unforeseen issues. I have noticed two main types of issues:

  1. pipx list fails if pipx install is ongoing due to missing metadata
  2. if shared libraries are outdated, any pipx command will trigger a shared libraries upgrade, which will cause concurrent commands to fail

How to reproduce

Scenario 1

import subprocess
from concurrent.futures import ThreadPoolExecutor
from typing import List

cmd = ["pipx", "list"]
cmd_list = [cmd] * 5 + ["pipx", "install", "pycowsay"]
with ThreadPoolExecutor() as executor:
    results: List[subprocess.CompletedProcess] = list(executor.map(subprocess.run, cmd_list))

print(results)

Scenario 2 as above, but remove the pipx install and ensure shared libraries are outdated, for example by running in a docker container with outdated libraries

Expected behavior Don't fail, but wait for the concurrent process to finish (debatable)

At the very least I'd expect pipx list not to fail with exit code 1 when a pipx install is ongoing

贡献者指南