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

Long print() statements can cause "ERROR: Application Failed to Start" #2

Open
ADevAJ opened this issue Jun 19, 2024 · 2 comments
Open

Comments

@ADevAJ
Copy link

ADevAJ commented Jun 19, 2024

mre_printerr

mre_pprinterr.zip

In my textual apps, I've often used print() statements before I call app.run() to push values of configuration files, variables, database lookups etc to the terminal, prior to textual TUI launch. Sometimes, these printouts get quite lengthy...

When I first attempted to run said apps with textual-serve v1.0.1 I got ERROR Application Failed to Start as per screenshot above.
Attached is Python MRE showing how changing the size of the text can cause reproduce error.

I assume this is because some kind of stack is being populated at the start of the app launch and is being overflown by excessively long print statements.

I think t's totally OK not to support long print calls, but perhaps a more descriptive error message could help users who encounter this like I did.

@willmcgugan
Copy link
Contributor

Textual-serve attempts to detect an App. If it doesn't get the response it expects, it assumes the command is broken. You might want to pass a switch / env variable to prevent your command from writing to stdout.

@ADevAJ
Copy link
Author

ADevAJ commented Aug 27, 2024

Wanted to update here that suppressing print() via sys.stdout = open(os.devnull, 'w') indeed worked for getting my app to run.

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

2 participants