CLI: when using --keep, do not disconnect before being interrupted wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Wed, 05 Oct 2022 20:15:28 +0200
branchwxPython4
changeset 3618 f08b59f7c00a
parent 3617 c3aae4c95bc1
child 3619 f75b11506fb2
CLI: when using --keep, do not disconnect before being interrupted
Beremiz_cli.py
--- a/Beremiz_cli.py	Wed Oct 05 16:10:17 2022 +0200
+++ b/Beremiz_cli.py	Wed Oct 05 20:15:28 2022 +0200
@@ -5,11 +5,11 @@
 import posixpath
 import sys
 import time
+
 from functools import wraps
+from importlib import import_module
 
 import click
-from importlib import import_module
-
 
 class CLISession(object):
     def __init__(self, **kwargs):
@@ -104,12 +104,15 @@
                 click.echo("Command sequence aborted")
             break
 
-    session.controller.finish()
-
     if session.keep:
         click.echo("Press Ctrl+C to quit")
-        while True:
-            time.sleep(1)
+        try:
+            while True:
+                time.sleep(1)
+        except KeyboardInterrupt:
+            pass
+
+    session.controller.finish()
 
     return ret