CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 17 Jul 2022 18:07:46 +0200
changeset 3548 da7b461f54b7
parent 3547 8a9a7d180b93
child 3549 0af7b6a96c53
CLI: Explicitely wait for user interrupt (-k) and flush stdout each line.
Beremiz_cli.py
CLIController.py
--- a/Beremiz_cli.py	Sun Jul 17 17:49:34 2022 +0200
+++ b/Beremiz_cli.py	Sun Jul 17 18:07:46 2022 +0200
@@ -4,6 +4,7 @@
 import os
 import posixpath
 import sys
+import time
 from functools import wraps
 
 import click
@@ -105,6 +106,11 @@
 
     session.controller.finish()
 
+    if session.keep:
+        click.echo("Press Ctrl+C to quit")
+        while True:
+            time.sleep(1)
+
     return ret
 
 if __name__ == '__main__':
--- a/CLIController.py	Sun Jul 17 17:49:34 2022 +0200
+++ b/CLIController.py	Sun Jul 17 18:07:46 2022 +0200
@@ -22,6 +22,7 @@
             if self.crlfpending:
                 sys.stdout.write("\n")
             sys.stdout.write(s)
+            sys.stdout.flush()
             self.crlfpending = 0
 
     def write_error(self, s):