Skip to content

Commit 5613813

Browse files
RealOrangeOneWillB97
authored andcommitted
Flush the log file for each write
This allows the log file to function `sync`, whilst keeping the benefit of an `async` mount for everything else
1 parent b4a2614 commit 5613813

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

runusb/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,13 @@ def _log_output(self, pipe: IO[str]) -> None:
346346
347347
This is done in a separate thread to avoid blocking the main thread.
348348
"""
349+
log_fileno = self.handler.stream.fileno()
350+
349351
for line in iter(pipe.readline, ''):
350352
USERCODE_LOGGER.log(USERCODE_LEVEL, line.rstrip('\n'))
353+
354+
# Forcefully sync the file, regardless of how it was mounted
355+
os.fsync(log_fileno)
351356
LOGGER.info('Process output finished')
352357

353358
def _rotate_old_logs(self, log_dir: str) -> None:

0 commit comments

Comments
 (0)