pdm icon indicating copy to clipboard operation
pdm copied to clipboard

`pdm install` cannot be interrupted with ^C on Linux

Open whitequark opened this issue 2 years ago • 2 comments

  • [x] I have searched the issue tracker and believe that this is not a duplicate.

There are a few issues dealing with ^C but none seem to be related to this problem specifically.

Steps to reproduce

Run a pdm install command somewhere with a large lockfile, then press Ctrl+C

Actual behavior

Something like this:

$ pdm install
The saved Python interpreter doesn't match the project's requirement. Trying to find another one.
python.use_venv is on, creating a virtualenv for this project...
Virtualenv is created successfully at /home/whitequark/Projects/zig-pypi/.venv
Synchronizing working set with lock file: 30 to add, 0 to update, 0 to remove

  ✔ Install wheel 0.38.4 successful
  ⠦ Installing bleach 6.0.0...
  ⠦ Installing certifi 2023.7.22...
  ⠦ Installing cffi 1.15.1...
  ⠦ Installing charset-normalizer 3.2.0...
  ⠦ Installing cryptography 41.0.3...
  ⠦ Installing docutils 0.20.1...
  ⠦ Installing idna 3.4...
  ⠦ Installing importlib-metadata 6.7.0...
Traceback (most recent call last):
  File "/home/whitequark/.local/bin/pdm", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 290, in main
    return Core().main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 203, in main
    self.handle(project, options)
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/core.py", line 157, in handle
    command.handle(project, options)
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/commands/install.py", line 95, in handle
    actions.do_sync(
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/cli/actions.py", line 213, in do_sync
    synchronizer.synchronize()
  File "/home/whitequark/.local/pipx/venvs/pdm/lib/python3.11/site-packages/pdm/installers/synchronizers.py", line 430, in synchronize
    with self.create_executor() as executor:
  File "/usr/lib/python3.11/concurrent/futures/_base.py", line 647, in __exit__
    self.shutdown(wait=True)
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 235, in shutdown
    t.join()
  File "/usr/lib/python3.11/threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.11/threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
  ✔ Install certifi 2023.7.22 successful
r  ✔ Install bleach 6.0.0 successful
  ✔ Install idna 3.4 successful
m   ✔ Install jaraco-classes 3.2.3 successful
  ✔ Install jeepney 0.8.0 successful
  ✔ Install docutils 0.20.1 successful
  ✔ Install importlib-metadata 6.7.0 successful
^CException ignored in: <module 'threading' from '/usr/lib/python3.11/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1553, in _shutdown
    atexit_call()
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 31, in _python_exit
    t.join()
  File "/usr/lib/python3.11/threading.py", line 1112, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.11/threading.py", line 1132, in _wait_for_tstate_lock
    if lock.acquire(block, timeout):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt:
  ✔ Install libarchive-c 5.0 successful

Expected behavior

The command terminating immediately on the first Ctrl+C press.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.8.2
Python Interpreter:
  /home/whitequark/Projects/zig-pypi/.venv/bin/python (3.11)
Project Root:
  /home/whitequark/Projects/zig-pypi
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.11.2",
  "os_name": "posix",
  "platform_machine": "x86_64",
  "platform_release": "6.1.0-9-amd64",
  "platform_system": "Linux",
  "platform_version": "#1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08)",
  "python_full_version": "3.11.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "linux"
}

whitequark avatar Aug 12 '23 17:08 whitequark

Since it is not breaking, I would like to mark it as low priority and leave it to potential contributors.

frostming avatar Aug 13 '23 10:08 frostming

I think the main potential issue here is ending up with a corrupted virtualenv, though I am not sure how likely is that.

whitequark avatar Aug 13 '23 15:08 whitequark