-
-
Notifications
You must be signed in to change notification settings - Fork 995
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
Flush after writting JSON to stdout #727
Comments
Writing a newline to stdout (as well as exiting the process) already causes a import sys
import time
for i in range(3):
sys.stdout.write("foo")
time.sleep(1)
sys.stdout.write("\n") # causes "foofoofoo" to appear
sys.stdout.write("bar") # doesn't get shown/flushed until process ends
time.sleep(3) What exactly are "some cases"? What are you trying to do where it doesn't work? |
Hi @mikf sorry for late response. I found out that problem is only with git bash (mingw64). Windows cmd and powershell prints whole json (without explicit flush). gallery-dl v1.14.1 |
… and remove the dead handle_finalize() method, which is never called since DataJob() overrides run().
There are apparently some problems with cygwin/mingw and Python's detection whether stdout etc is a TTY or not and its auto-flush behavior, which I've never heard about before:
Well, I've now added an explicit |
In some cases, in resulting JSON is missing last few lines or output is missing entirely.
This could be fixed by flushing buffer to file after write
gallery-dl/gallery_dl/util.py
Line 113 in 90491ab
fp.flush()
The text was updated successfully, but these errors were encountered: