Skip to content

Commit

Permalink
Flush stdout buffer before print to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankamkin authored and Denis-Averin committed Feb 27, 2024
1 parent c421acf commit 62c3656
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/check-urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ def url_checker(num_workers=8):
(url, filename) = item
workers[i] = create_new_task(url, filename)
time.sleep(0.2)
print("Worker finished")
# Flush stdout buffer before print to stderr
print("Worker finished", flush=True)


def main(files):
Expand All @@ -218,7 +219,9 @@ def main(files):
checker.join()

for url, files in BROKEN_URLS.items():
print("BROKEN URL: '%s' in files: %s" % (url, ", ".join(files)), file=sys.stderr)
message = "BROKEN URL: '%s' in files: %s" % (url, ", ".join(files))
print(message, file=sys.stdout)
print(message, file=sys.stderr, flush=True)
if BROKEN_URLS:
exit(1)

Expand Down

0 comments on commit 62c3656

Please sign in to comment.