Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Turns out print() does not flush I/O by default
Browse files Browse the repository at this point in the history
and sys.stderr is not unbuffered except in interactive mode.  This is important here
a) To ensure that the 'Waiting...' message is displayed before waiting on flock() and
b) To ensure the last message is displayed before exec()-ing.
  • Loading branch information
embray committed Oct 25, 2017
1 parent 60c7670 commit e960c8a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bin/sage-flock
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def main(argv=None):

print("Waiting for {0} lock to run {1} ... ".format(
kind, ' '.join(pipes.quote(arg) for arg in command)), end='',
file=sys.stderr)
file=sys.stderr, flush=True)
fcntl.flock(lock, locktype)
print("ok", file=sys.stderr)
print("ok", file=sys.stderr, flush=True)

os.execvp(command[0], command)

Expand Down

0 comments on commit e960c8a

Please sign in to comment.