-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Use os.execvp
for poetry run
#1236
Use os.execvp
for poetry run
#1236
Conversation
👍 on this however using |
specifically you want this file: https://github.com/bertjwregeer/vrun/blob/master/src/vrun/oscompat.py |
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 run
usessubprocess.call
to run the other program, making poetry spawn a new child process.The problem is when
SIGTERM
is handed over; poetry does not pass it to the child process, instead terminates itself and makes zombie processes.So I changed
poetry run
to 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.py
and tried to kill it.Before
Fixed
Test - scripts feature
I added the following lines to
pyprojects.toml
.Then ran
poetry run tester
and tried to kill it.Before
Fixed