Skip to content

Commit 7dfea8f

Browse files
committed
main: make debug() flush its output to stderr on every print
Signed-off-by: Cedric Hombourger <[email protected]>
1 parent 3112ab5 commit 7dfea8f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

debian/mtda.service

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description=Multi-Tenant Device Access
33

44
[Service]
55
Type=simple
6-
ExecStart=/usr/bin/python3 -u /usr/bin/mtda-cli -d -n
6+
ExecStart=/usr/bin/mtda-cli -d -n
77

88
[Install]
99
WantedBy=multi-user.target

mtda/main.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ def debug(self, level, msg):
292292
prefix = "# debug%d: " % level
293293
msg = str(msg).replace("\n", "\n%s ... " % prefix)
294294
lines = msg.splitlines()
295+
sys.stderr.buffer.write(prefix.encode("utf-8"))
295296
for line in lines:
296-
line = _make_printable(line)
297-
print("%s%s" % (prefix, line), file=sys.stderr)
297+
sys.stderr.buffer.write(_make_printable(line).encode("utf-8"))
298+
sys.stderr.buffer.write(b"\n")
299+
sys.stderr.buffer.flush()
298300

299301
def env_get(self, name, session=None):
300302
self.mtda.debug(3, "env_get()")

0 commit comments

Comments
 (0)