Skip to content

Relay exit code in poetry run - #2904

Closed
pawamoy wants to merge 2 commits into
python-poetry:masterfrom
pawamoy:fix-exit-code-relaying
Closed

pawamoy wants to merge 2 commits into
python-poetry:masterfrom
pawamoy:fix-exit-code-relaying

Conversation

@pawamoy

@pawamoy pawamoy commented Sep 11, 2020 •

Copy link
Copy Markdown

Pull Request Check List

Resolves: #2369

  • Added tests for changed code.
  • Updated documentation for changed code.

I'm a bit stuck. While testing the run command, it seems the tester.io buffer stays empty. Why is that? The command prints things on stdout, the buffer should get them.

Also, it seems the fix has no effect? If I navigated through the code correctly, the script is ultimately run like this:

return os.execvp("python", [
    "python", "-c",
        "import sys; from importlib import import_module; "
        "sys.argv = ('relay', '2'); sys.exit(import_module('project.main').relay())"
])

os.execvp does not return, and rather replaces the current process, so anyway the exit code should be 2, and tester.status_code stays at 0.

Any idea? 😕

@pawamoy pawamoy changed the title wip Relay exit code in poetry run Sep 11, 2020
@pawamoy

pawamoy commented Sep 11, 2020 •

Copy link
Copy Markdown
Author

Well OK, the fix does fix the issue, it's just hard to test it. I noticed that the env has _execute = False, so the script is not actually ran, so that explains why the status code is not 2. I tried setting env._execute = True and patching os.execvp with subprocess.call, but the import machinery cannot find the project package. Maybe I'd need to install or fake the installation of the package?

I'm a bit lost 😅

But the fix should actually work 🙂

@pawamoy

pawamoy commented May 25, 2021

Copy link
Copy Markdown
Author

I'm using PDM now, not interested anymore, feel free to reopen, reuse the code in another PR, or simply ping me!

@pawamoy pawamoy closed this May 25, 2021
@pawamoy pawamoy mentioned this pull request Jun 18, 2021
2 tasks done
@github-actions

github-actions Bot commented Mar 1, 2024

Copy link
Copy Markdown

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.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

poetry run does not relay exit code

1 participant