Always flush after each message
It was already ok before in interactive terminals, but when invloving pipes to e.g. tee or file redirects, the output got buffered for such a long time, it made it seem like the script suddenly broke.
This commit is contained in:
parent
aafac2d776
commit
73e62c2f2a
1 changed files with 3 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ from typing import Any, Optional, TypeAlias, Union
|
|||
VERSION = "0.1"
|
||||
DEBUG = True
|
||||
DRYRUN = False
|
||||
FLUSH = True
|
||||
|
||||
NOW = datetime.datetime.now(datetime.timezone.utc)
|
||||
|
||||
|
|
@ -45,11 +46,11 @@ class Config(argparse.Namespace):
|
|||
|
||||
# Utils
|
||||
def printerr(str: str) -> None:
|
||||
print(str, file=sys.stderr)
|
||||
print(str, file=sys.stderr, flush=FLUSH)
|
||||
|
||||
def printdbg(str: str) -> None:
|
||||
if DEBUG:
|
||||
print(str)
|
||||
print(str, flush=FLUSH)
|
||||
|
||||
def is_http_error(resp: httpx.Response) -> bool:
|
||||
return resp.status_code >= 300 or resp.status_code < 200
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue