trogon icon indicating copy to clipboard operation
trogon copied to clipboard

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

Open bigbirdcode opened this issue 9 months ago • 1 comments
trafficstars

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 avatar Jan 26 '25 19:01 bigbirdcode

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

https://github.com/python/cpython/issues/101191 https://github.com/python/cpython/issues/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.

bigbirdcode avatar Jan 28 '25 22:01 bigbirdcode