Skip to content

Commit 9e969dc

Browse files
author
Chad Smith
authored
do not use multiprocessing.Pool if unavailable (#410)
1 parent a4aad7c commit 9e969dc

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

docs/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
dev
22

3+
0.15.3.1
4+
- [bugfix] Workaround multiprocessing issues on certain platforms (#229)
5+
36
0.15.3.0
47
- [feature] Use symlinks on Windows when symlinks are available
58

src/pipx/commands/list_packages.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
try:
2-
# Instantiating a Pool() attempts to import multiprocessing.synchronize,
3-
# which fails if the underlying OS does not support semaphores.
4-
# Here, we import ahead of time to decide which Pool implementation to use:
5-
# one backed by Processes (the default), or one backed by Threads
6-
import multiprocessing.synchronize # noqa: F401
7-
except ImportError:
8-
# Fallback to Threads on platforms that do not support semaphores
9-
# https://github.com/pipxproject/pipx/issues/229
10-
from multiprocessing.dummy import Pool
11-
else:
12-
from multiprocessing import Pool
13-
1+
from typing import Optional, Callable
142
from pipx import constants
153
from pipx.colors import bold
164
from pipx.commands.common import get_package_summary
175
from pipx.emojies import sleep
186
from pipx.venv import VenvContainer
197

8+
Pool: Optional[Callable]
9+
try:
10+
import multiprocessing.synchronize # noqa: F401
11+
from multiprocessing import Pool
12+
except ImportError:
13+
Pool = None
14+
2015

2116
def list_packages(venv_container: VenvContainer):
2217
dirs = list(sorted(venv_container.iter_venv_dirs()))
@@ -29,6 +24,11 @@ def list_packages(venv_container: VenvContainer):
2924

3025
venv_container.verify_shared_libs()
3126

32-
with Pool() as p:
33-
for package_summary in p.map(get_package_summary, dirs):
27+
if Pool:
28+
with Pool() as p:
29+
for package_summary in p.map(get_package_summary, dirs):
30+
print(package_summary)
31+
else:
32+
for d in dirs:
33+
package_summary = get_package_summary(d)
3434
print(package_summary)

src/pipx/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version_info__ = (0, 15, 3, 0)
1+
__version_info__ = (0, 15, 3, 1)
22
__version__ = ".".join(str(i) for i in __version_info__)

0 commit comments

Comments
 (0)