Textualize / textual-serve

Serve Textual apps locally
MIT License
168 stars 8 forks source link

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

Open ADevAJ opened 3 months ago

ADevAJ commented 3 months ago
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 commented 3 months ago

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 commented 1 month ago

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