From 7e7340665dc786e543611727147731daf11cc577 Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Wed, 14 Jun 2023 16:50:44 -0500 Subject: [PATCH 1/2] Revert "Don't catch KeyboardInterrupt twice for REPL server (#1498)" This reverts commit d6dce903adfee609330cd65cb8766057251f55c9. --- pymodbus/repl/server/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pymodbus/repl/server/main.py b/pymodbus/repl/server/main.py index 1c72e9b0a..d986bee5c 100644 --- a/pymodbus/repl/server/main.py +++ b/pymodbus/repl/server/main.py @@ -198,12 +198,15 @@ def run( **web_app_config, **modbus_config, ) - if repl: - loop.run_until_complete(run_repl(app)) - else: + try: loop.run_until_complete(app.run_async(repl)) + if repl: + loop.run_until_complete(run_repl(app)) loop.run_forever() + except CANCELLED_ERROR: + print("Done!!!!!") + if __name__ == "__main__": app() From 0d5747cab2d56ce0ac48fb28ab3f6d7043c56a99 Mon Sep 17 00:00:00 2001 From: Alex Ruddick Date: Wed, 14 Jun 2023 16:52:25 -0500 Subject: [PATCH 2/2] Don't catch KeyboardInterrupt twice (second attempt) --- pymodbus/repl/server/main.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pymodbus/repl/server/main.py b/pymodbus/repl/server/main.py index d986bee5c..bb01e64d7 100644 --- a/pymodbus/repl/server/main.py +++ b/pymodbus/repl/server/main.py @@ -198,15 +198,12 @@ def run( **web_app_config, **modbus_config, ) - try: - loop.run_until_complete(app.run_async(repl)) - if repl: - loop.run_until_complete(run_repl(app)) + loop.run_until_complete(app.run_async(repl)) + if repl: + loop.run_until_complete(run_repl(app)) + else: loop.run_forever() - except CANCELLED_ERROR: - print("Done!!!!!") - if __name__ == "__main__": app()