Skip to content

REPL server needs CTRL+C twice to exit #1497

@alexrudd2

Description

@alexrudd2
  • Python: 3.11
  • OS: MacOS
  • Pymodbus: 9f66ab5

REPL server needs to be exited twice; non-REPL server exits fine. I think this was introduced in c395566.

except CANCELLED_ERROR:
print("Done!!!!!")

❯ pymodbus.server run --modbus-server tcp --framer socket --slave-id 1 --slave-id 4 --random 2

__________                          .______.                    _________
\______   \___.__. _____   ____   __| _/\_ |__  __ __  ______  /   _____/ ______________  __ ___________
 |     ___<   |  |/     \ /  _ \ / __ |  | __ \|  |  \/  ___/  \_____  \_/ __ \_  __ \  \/ // __ \_  __ \\
 |    |    \___  |  Y Y  (  <_> ) /_/ |  | \_\ \  |  /\___ \   /        \  ___/|  | \/\   /\  ___/|  | \/
 |____|    / ____|__|_|  /\____/\____ |  |___  /____//____  > /_______  /\___  >__|    \_/  \___  >__|
           \/          \/            \/      \/           \/          \/     \/                 \/


SERVER >

Enter CTRL+C (or type exit)
Bye Bye!!!
Enter CTRL+C again to actually exit

^C
Aborted.

The non-REPL server exits correctly on a single CTRL+C:

❯ pymodbus.server --no-repl --verbose run  --modbus-server tcp --framer socket --slave-id 1 --slave-id 4 --random 2 --modbus-port 5020
2023-04-18 00:05:52,276 INFO  logging:96 Modbus server started

Reactive Modbus Server started.
======== Running on http://localhost:8080 ========

===========================================================================
Example Usage:
curl -X POST http://localhost:8080 -d "{"response_type": "error", "error_code": 4}"
===========================================================================

2023-04-18 00:05:52,279 INFO  logging:96 Server(TCP) listening.
^C
Aborted.

Also, there's a useless try/except block that never gets called.
https://github.com/pymodbus-dev/pymodbus/blob/dev/pymodbus/repl/server/main.py#L207-L208

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions