Start and stop server from v2.5.3 to v3.0.0 #2541
-
Hello everyone ! I have an application using v2.5.3 which spawns multiple These slaves contains either a The implementation is really simple and look like this. from threading import Thread
from typing import Any
class ModbusServerManager:
"""Manages the Modbus server lifecycle."""
def __init__(self, server: Any) -> None:
self._server = server
self._thread_server = Thread(
target=self._server.serve_forever,
)
def start(self) -> None:
self._thread_server.start()
def stop(self) -> None:
if self._thread_server.is_alive():
self._server.shutdown()
self._thread_server.join() I have to update to version v3.0.0 because I need to use the package I've spent multiple days trying to adapt this code using the new async pattern you adopted from this version, without any success. I've looked for your examples, your unit tests, the documentation of asyncio, but I don't manage to make it work. Should I use some tasks, keep using a thread, use await directly? I'm a bit lost to be honest 😕... Note that I want the modification to be minimal and not use I hope you'll be able to help me ! Thank in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
First of all 3.0.0 is very old and should not be used. Current version is 3.8.4 Secondly have a look at our examples, you can ether use startserver or continue use modbusserver which e.g. have a serve_forever public method. However please be aware that the 3.x server code is async. |
Beta Was this translation helpful? Give feedback.
-
Please also be aware this is the pymodbus project, NOT python3-modbus ! We have all source available on github, including unit test etc, I have no idea about the project you want to use. |
Beta Was this translation helpful? Give feedback.
-
It is of course up to you, which package you want to use, but it must be considered quite unusual that the maintainers of Debian include a release candidate instead of the proper release. You might not be able to use pip in the standard environment, but you can create a virtual environment and in that install the packages you want (you can even install different python versions). I do that on my raspberry PIs, exactly to get around the Debian limitations. Running the server in background is not a feature of pymodbus, but at a standard python functionality. We show how to use pymodbus not python :-) If you want to you can simply run start server in background, with the method of your preference, pymodbus do not care. And just for reference a lot of our unit test run the server in background (of course using asyncio). Please be aware that especially the release candidate had some severe bugs, which we will not be able to help you with. |
Beta Was this translation helpful? Give feedback.
-
Neither Jan nor anyone else on this project have involvement with Debian's packaging of I note that |
Beta Was this translation helpful? Give feedback.
It is of course up to you, which package you want to use, but it must be considered quite unusual that the maintainers of Debian include a release candidate instead of the proper release.
You might not be able to use pip in the standard environment, but you can create a virtual environment and in that install the packages you want (you can even install different python versions). I do that on my raspberry PIs, exactly to get around the Debian limitations.
Running the server in background is not a feature of pymodbus, but at a standard python functionality. We show how to use pymodbus not python :-)
If you want to you can simply run start server in background, with the method of your prefe…