Skip to content

Commit

Permalink
Flush output to notify without blocking in http-disk-server callers
Browse files Browse the repository at this point in the history
Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.tech>
  • Loading branch information
Wescoeur committed Nov 15, 2024
1 parent 5549312 commit 776b1cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions http_disk_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def check_bindable(port):

def eprint(str):
print(OUTPUT_PREFIX + str, file=sys.stderr)
# Flush to ensure we can read messages in another process without waiting.
sys.stderr.flush()

def is_drbd_device(path):
try:
Expand Down
6 changes: 2 additions & 4 deletions nbd_http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def run_or_ignore(fun):

def eprint(str):
print(OUTPUT_PREFIX + str, file=sys.stderr)
# Flush to ensure we can read messages in another process without waiting.
sys.stderr.flush()

# -----------------------------------------------------------------------------

Expand Down Expand Up @@ -247,10 +249,6 @@ def clean_paths():

try:
nbd = attach_nbd(socket_path, nbd_name, pid_path)
# Flush to ensure we can read output (like NBD device used)
# in another process without waiting.
sys.stdout.flush()
sys.stderr.flush()
while True:
try:
if SIGTERM_RECEIVED:
Expand Down

0 comments on commit 776b1cd

Please sign in to comment.