fix: line-buffer sync output so a redirected log shows progress live
A sync runs for hours and is normally watched through a redirected log, where Python's block buffering withheld the per-source progress lines until they happened to flush. The gallery-dl subprocesses write to the same descriptor unbuffered, so the log also interleaved out of order. Reconfiguring the streams in-process rather than relying on `python3 -u` means it holds however the script is invoked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -484,6 +484,13 @@ def publish(staging: Path, dest: str, dry_run: bool) -> int:
|
||||
|
||||
|
||||
def main() -> int:
|
||||
# A sync runs for hours and is normally watched through a redirected log,
|
||||
# where Python's block buffering would withhold progress until it happened
|
||||
# to flush -- and the gallery-dl subprocesses write to the same descriptor
|
||||
# unbuffered, so the log would also interleave out of order.
|
||||
sys.stdout.reconfigure(line_buffering=True)
|
||||
sys.stderr.reconfigure(line_buffering=True)
|
||||
|
||||
ap = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
ap.add_argument("--index", required=True,
|
||||
|
||||
Reference in New Issue
Block a user