Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Process pool termination when running Black with Pipenv inside venv #2108

Closed
felix-hilden opened this issue Apr 15, 2021 · 2 comments
Labels
C: configuration CLI and configuration T: bug Something isn't working

Comments

@felix-hilden
Copy link
Collaborator

felix-hilden commented Apr 15, 2021

From #2106: I've encountered a peculiar error when installing and running Black.

Environment

  • Windows 10
  • Python 3.7.2
  • CMD with admin privileges
  • venv
  • pipenv
  • black dev install

Specifically, the issue does not appear when using pipenv only (without venv).

Reproducing

First I followed the contributing guide, which suggested using a pre-existing virtualenvironment is fine.

git clone https://github.com/psf/black black-mwe
cd black-mwe

python -m venv venv
"./venv/Scripts/activate.bat"

pip install pipenv
pipenv install --dev
pipenv shell

pre-commit install
pip install -r test_requirements.txt
pip install -e .[d]

Then both of these commands fail:

pre-commit run -a
black .

Pre-commit fails with:

this output
- hook id: black
- exit code: 123

Process SpawnProcess-1:
Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\multiprocessing\process.py", line 297, in _bootstrap
    self.run()
  File "C:\Program Files\Python37\lib\multiprocessing\process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Program Files\Python37\lib\concurrent\futures\process.py", line 226, in _process_worker
    call_item = call_queue.get(block=True)
  File "C:\Program Files\Python37\lib\multiprocessing\queues.py", line 93, in get
    with self._rlock:
  File "C:\Program Files\Python37\lib\multiprocessing\synchronize.py", line 95, in __enter__
    return self._semlock.__enter__()
PermissionError: [WinError 5] Access is denied

leading to a bunch of error: cannot format file.py: A process in the process pool was terminated abruptly while the future was running or pending. Other pre-commit tasks are run successfully.

And running Black simply leaves the process hanging. Interrupting it produces a similar error message for 4 processes (= core count?), with an additional message "Future exception was never retrieved".


I'm a bit over my head with this, since I've never used pipenv, and only used venv at the very surface level. Knowing the setup works without venv is completely acceptable to me, but I thought this could be worth addressing at least on the documentation level if nobody has the time to install Windows and start digging around, since it's explicitly mentioned in the contributing guide that existing virtualenvs are ok 😄

@felix-hilden felix-hilden added the T: bug Something isn't working label Apr 15, 2021
@felix-hilden
Copy link
Collaborator Author

I also managed to pull through with my WSL running Debian 10 and it had no such issues, so my guess is that this is specific to Windows.

@felix-hilden felix-hilden changed the title Process pool termination when running Black with Pipenv inside venv Windows: Process pool termination when running Black with Pipenv inside venv Apr 15, 2021
@JelleZijlstra JelleZijlstra added the C: configuration CLI and configuration label May 30, 2021
@felix-hilden
Copy link
Collaborator Author

Well we ain't using pipenv anymore 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration CLI and configuration T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants