python-poetry / python-poetry/poetry
Plugins cannot respond to `TERMINATE` event on non-Windows systems after `poetry run`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
- Poetry version: 1.5.1
- Python version: 3.10.7
- OS version and name: Windows 11
- pyproject.toml: Any
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption) and have included the output below.
Issue
On non-Windows systems, poetry run uses os.execvpe:
Because of how this function replaces the current process, a plugin cannot respond to the TERMINATE event. atexit hooks are also not called.
Could subprocess.Popen simply be used for all systems instead of Windows only?
My use case is that my plugin makes some temporary modifications to set the version number, and it needs to revert them when the command is done. Right now, I just have the plugin ignore poetry run and poetry shell since it can't clean up after them.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/poetry/utils/env/generic_env.py at the referenced os.execvpe call and compare its non-Windows behavior with the Windows subprocess.Popen path. Reproduce poetry run with a plugin that listens for the TERMINATE event, then verify that the event and cleanup hooks run after the command completes on non-Windows systems.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100