Skip to content
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

I get back my prompt when my script is started by Trogon #106

Open
bigbirdcode opened this issue Jan 26, 2025 · 1 comment
Open

I get back my prompt when my script is started by Trogon #106

bigbirdcode opened this issue Jan 26, 2025 · 1 comment

Comments

@bigbirdcode
Copy link

bigbirdcode commented Jan 26, 2025

I have the following example script:

import time

import click
from trogon import tui


@tui()
@click.command()
def cli():
    time.sleep(2)  # simulating some longer task
    click.echo("Hello from trogon-try!")
    click.echo("This is the second output line.")


if __name__ == "__main__":
    cli()

When I execute it with Trogon then Trogon starts the execution of my script, but meanwhile I get back the prompt. So my script is running in the background and writing to the console. This is really confusing and can be the source of errors.

See in the below screenshot how it looks.

Image

Note: I'm using Windows.

@bigbirdcode
Copy link
Author

bigbirdcode commented Jan 28, 2025

I have searched a bit more and the problem is that os.execvp() is not working on Windows. See also:

python/cpython#101191
python/cpython#63323

Instead I suggest something like:

    if sys.platform == "win32":
        sys.exit(subprocess.call(arguments))
    else:
        os.execvp(program_name, arguments)

Unfortunately it is not that easy, will need better env handling. I'll continue my investigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant