Skip to content

[dev] Fix premature shutdown in simulator example and update README instructions #2872

@FedericoMusa

Description

@FedericoMusa

Versions
Python: 3.13

OS: Windows 10 (MINGW64)

Pymodbus: 4.0.0.dev8 (branch dev)

Modbus Hardware: None (Simulator)

Pymodbus Specific
Server: tcp - async (Simulator)

Client: tcp - async (Simulator)

Description
I am reporting an inconsistency in the current dev branch regarding the simulator's usability as a standalone tool.

Premature Shutdown in Example: The examples/simulator.py script is currently structured as a one-shot test. As seen in the attached code snippet, it calls await task.stop() immediately after the test calls, which triggers a graceful shutdown of both the Modbus and HTTP servers.

Web UI Inaccessibility: Because of this immediate shutdown, the Web UI (listening on port 8081) becomes unreachable for manual interaction.

Documentation Gap: The README.rst still points to the deprecated v3_simulator.py script, which no longer exists in the examples/ directory.

Expected behavior: The simulator example should remain persistent to allow users to interact with the Web interface. I have verified that replacing task.stop() with a persistent wait allows the Web UI to function correctly.

Code and Logs
Execution Log (Premature Shutdown):

Plaintext
2026-02-09 17:20:29,987 INFO base:89 Server listening.
2026-02-09 17:20:30,180 INFO http_server:226 Stopping modbus server
2026-02-09 17:20:30,181 INFO base:93 Server graceful shutdown.
2026-02-09 17:20:30,181 INFO http_server:232 Modbus server Stopped

Code causing the issue (examples/simulator.py):

Image Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions