Use os.execvp for poetry run#1236
Conversation
|
👍 on this however using |
|
I found in Windows,
So I think poetry needs to create a new process and wait until the new one exits. (https://github.com/bertjwregeer/vrun/blob/a726be8106a00621361f60079ac403e5bc16864a/src/vrun/oscompat.py#L34) |
|
If you try to use the exec calls on Windows you get into a really weird state where the process you are running can't be controlled from the cmd.exe window it is spawned from. You need to do the whole popen dance so that you can send key strokes from the foreground to the process that was spawned on Windows. |
|
I see that @pbzweihander got there before me! :-D Please steal my code, I didn't come to that conclusion the easy way! |
ae1b0a5 to
69a1ac2
Compare
69a1ac2 to
e5ebabe
Compare
|
Now I think this PR is ready to be merged since I see no more blockers. |
|
Thanks for your contribution. I'm not sure when someone will have a chance to dig into this. I imagine its pretty hard to add an automated test for this? |
|
What kind of tests are you looking for? |
e5ebabe to
2c467a9
Compare
|
@sdispater so, are there plans to merge this one? :) |
|
Thanks a lot for this PR! |
* Use os.execvp for poetry run * Use subprocess.Popen for Windows * Handle env kwargs
* Use os.execvp for poetry run * Use subprocess.Popen for Windows * Handle env kwargs
|
Does this have any effect on performance? |
|
It'll boost performance since |
|
I think this broke calling scripts on Windows - if I do |
|
It’s actually calling |
|
I've noticed killing poetry processes with SIGTERM creates a status code of 143. While that error code does indicate graceful termination after receiving SIGTERM, why not just return 0? |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |

This resolves #993.
poetry runusessubprocess.callto run the other program, making poetry spawn a new child process.The problem is when
SIGTERMis handed over; poetry does not pass it to the child process, instead terminates itself and makes zombie processes.So I changed
poetry runto useos.execvp, so poetry will replace itself with a new process and properly handle signals.Test
I made this small script in
poetry/tester.py:Then ran
poetry run python poetry/tester.pyand tried to kill it.Before
Fixed
Test - scripts feature
I added the following lines to
pyprojects.toml.Then ran
poetry run testerand tried to kill it.Before
Fixed