Python script output doesn't print until script execution finished
I'm running Python scripts which can take a long time to finish running, due to that during the Python execution, print out to the screen the script stages so the users won't need to wait until the end without knowing what's going on. when I'm running vi Script-Server only when Python execution ends I get the complete STDOUT printed to the screen.
I found an ugly workaround which instead of printing out with print(), I'm printing using input() with Timeout of 1 sec before continuing before the user will able to prompt in, and then it prints out the messages in "real-time"
is this a bug or by design?
Hey, as far as i understand, this is how python buffering works
Try running python -u your_script.py
Alonel [email protected] schrieb am Sa., 10. Okt. 2020, 00:22:
I'm running Python scripts which can take a long time to finish running, due to that during the Python execution, print out to the screen the script stages so the users won't need to wait until the end without knowing what's going on. when I'm running vi Script-Server only when Python execution ends I get the complete STDOUT printed to the screen.
I found an ugly workaround which instead of printing out with print(), I'm printing using input() with Timeout of 1 sec before continuing before the user will able to prompt in, and then it prints out the messages in "real-time"
is this a bug or by design?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bugy/script-server/issues/349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJXPJKH3L7H4M6FXIRMLEDSJ6ELXANCNFSM4SKSN6BA .
Thanks that fix the issue for me.
I stumbled upon this inconvenience during testing again and decided to disable python buffering for called scripts (using PYTHONUNBUFFERED env variable). Hopefully, it won't break existing functionality and no one relies on buffering