Skip to content

Commit 0288348

Browse files
authored
Remove tornado. (#935)
1 parent 02105ce commit 0288348

File tree

11 files changed

+14
-626
lines changed

11 files changed

+14
-626
lines changed

README.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Remark: "Supports" means that we only test with those versions, lower versions (
3030
Summary
3131
------------------------------------------------------------
3232

33-
Pymodbus is a full Modbus protocol implementation using a synchronous or asynchronous core. The preferred mode for asynchronous communication is asyncio, however for the moment twisted and tornado are also supported (due to be removed or converted to a plugin in a later version).
33+
Pymodbus is a full Modbus protocol implementation using a synchronous or asynchronous core. The preferred mode for asynchronous communication is asyncio, however for the moment twisted are also supported (due to be removed or converted to a plugin in a later version).
3434

3535
Supported modbus communication modes: tcp, rtu-over-tcp, udp, serial, tls
3636

@@ -53,7 +53,7 @@ Client Features
5353
* Full read/write protocol on discrete and register
5454
* Most of the extended protocol (diagnostic/file/pipe/setting/information)
5555
* TCP, RTU-OVER-TCP, UDP, TLS, Serial ASCII, Serial RTU, and Serial Binary
56-
* asynchronous(powered by asyncio/twisted/tornado) and synchronous versions
56+
* asynchronous(powered by asyncio/twisted) and synchronous versions
5757
* Payload builder/decoder utilities
5858
* Pymodbus REPL for quick tests
5959
* Customable framer to allow for custom implementations
@@ -129,7 +129,6 @@ If you think, that something in the code is broken/not running well, please `ope
129129

130130
.. important::
131131
**Note For async clients, it is recommended to use `asyncio` as the async facilitator.**
132-
**If using tornado make sure the tornado version is `4.5.3` other versions of tornado can break the implementation**
133132

134133

135134
------------------------------------------------------------
@@ -171,8 +170,6 @@ Available options are:
171170

172171
- **twisted**, installs twisted as alternative to asyncio (will be removed in a future version).
173172

174-
- **tornado**, installs tornado as alternative to asyncio (will be removed in a future version).
175-
176173
- **documentation**, installs tools to generate documentation.
177174

178175
- **development**, installs development tools needed to enable test/check of pymodbus changes.

doc/source/library/pymodbus.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pymodbus\.client package
22
========================
33

4-
Pymodbus offers a :mod:`synchronous client <pymodbus.client.sync>`, and async clients based on :mod:`asyncio <pymodbus.client.asynchronous.async_io>`, :mod:`Tornado <pymodbus.client.asynchronous.tornado>`, and :mod:`Twisted <pymodbus.client.asynchronous.Twisted>`.
4+
Pymodbus offers a :mod:`synchronous client <pymodbus.client.sync>`, and async clients based on :mod:`asyncio <pymodbus.client.asynchronous.async_io>` and :mod:`Twisted <pymodbus.client.asynchronous.Twisted>`.
55

66
Each client shares a :mod:`common client mixin <pymodbus.client.common>` which offers simple methods for reading and writing.
77

pymodbus/client/asynchronous/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Async Modbus Client implementation based on Twisted, tornado and asyncio
1+
"""Async Modbus Client implementation based on Twisted and asyncio
22
33
Example run::
44
@@ -10,9 +10,6 @@
1010
from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient as Client
1111
from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient as Client
1212
13-
# For tornado based asynchronous client use
14-
event_loop, future = Client(schedulers.IO_LOOP, port=5020)
15-
1613
# For twisted based asynchronous client use
1714
event_loop, future = Client(schedulers.REACTOR, port=5020)
1815
@@ -23,9 +20,6 @@
2320
# a Future/deferred object which would be used to
2421
# add call backs to run asynchronously.
2522
26-
# The Actual client could be accessed with future.result() with Tornado
27-
# and future.result when using twisted
28-
2923
# For asyncio the actual client is returned and event loop is asyncio loop
3024
"""
3125
import logging

pymodbus/client/asynchronous/deprecated/__init__.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
warnings.simplefilter("always", DeprecationWarning)
55

66
WARNING = """
7-
Usage of "{}" is deprecated from 2.0.0 and will be removed in future releases.
8-
Use the new Async Modbus Client implementation based on Twisted, tornado
7+
Usage of "{}" is deprecated from 3.0.0 and will be removed in future releases.
8+
Use the new Async Modbus Client implementation based on Twisted
99
and asyncio
1010
------------------------------------------------------------------------
1111
@@ -19,9 +19,6 @@
1919
from pymodbus.client.asynchronous.serial import AsyncModbusSerialClient as Client
2020
from pymodbus.client.asynchronous.udp import AsyncModbusUDPClient as Client
2121
22-
# For tornado based asynchronous client use
23-
event_loop, future = Client(schedulers.IO_LOOP, port=5020)
24-
2522
# For twisted based asynchronous client use
2623
event_loop, deferred = Client(schedulers.REACTOR, port=5020)
2724
@@ -32,14 +29,10 @@
3229
# a Future/deferred object which would be used to
3330
# add call backs to run asynchronously.
3431
35-
# The Actual client could be accessed with future.result() with Tornado
36-
# and future.result when using twisted
37-
3832
# For asyncio the actual client is returned and event loop is asyncio loop
3933
4034
Refer:
4135
https://pymodbus.readthedocs.io/en/dev/source/example/async_twisted_client.html
42-
https://pymodbus.readthedocs.io/en/dev/source/example/async_tornado_client.html
4336
https://pymodbus.readthedocs.io/en/dev/source/example/async_asyncio_client.html
4437
4538
"""

pymodbus/client/asynchronous/factory/serial.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Factory to create asynchronous serial clients based on twisted/tornado/asyncio."""
1+
"""Factory to create asynchronous serial clients based on twisted/asyncio."""
22
# pylint: disable=missing-type-doc
33
import logging
44
import asyncio
@@ -69,29 +69,6 @@ def __init__(self, framer, *args, **kwargs):
6969
return proto, ser_client
7070

7171

72-
def io_loop_factory(port=None, framer=None, **kwargs):
73-
"""Create Tornado based asynchronous serial clients.
74-
75-
:param port: Serial port
76-
:param framer: Modbus Framer
77-
:param kwargs:
78-
:return: event_loop_thread and tornado future
79-
"""
80-
from tornado.ioloop import IOLoop # pylint: disable=import-outside-toplevel
81-
from pymodbus.client.asynchronous.tornado import ( # pylint: disable=import-outside-toplevel
82-
AsyncModbusSerialClient as Client,
83-
)
84-
85-
ioloop = IOLoop()
86-
protocol = EventLoopThread("ioloop", ioloop.start, ioloop.stop)
87-
protocol.start()
88-
client = Client(port=port, framer=framer, ioloop=ioloop, **kwargs)
89-
90-
future = client.connect()
91-
92-
return protocol, future
93-
94-
9572
def async_io_factory(port=None, framer=None, **kwargs):
9673
"""Create asyncio based asynchronous serial clients.
9774
@@ -121,18 +98,16 @@ def async_io_factory(port=None, framer=None, **kwargs):
12198
def get_factory(scheduler):
12299
"""Get protocol factory based on the backend scheduler being used.
123100
124-
:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
101+
:param scheduler: REACTOR/ASYNC_IO
125102
:return:
126103
:raises Exception: Failure
127104
"""
128105
if scheduler == schedulers.REACTOR:
129106
return reactor_factory
130-
if scheduler == schedulers.IO_LOOP:
131-
return io_loop_factory
132107
if scheduler == schedulers.ASYNC_IO:
133108
return async_io_factory
134109

135-
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.IO_LOOP}, {schedulers.ASYNC_IO}"
110+
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.ASYNC_IO}"
136111
_logger.warning(txt)
137112
txt = f'Invalid Scheduler "{scheduler}"'
138113
raise Exception(txt)

pymodbus/client/asynchronous/factory/tcp.py

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Factory to create asynchronous tcp clients based on twisted/tornado/asyncio."""
1+
"""Factory to create asynchronous tcp clients based on twisted/asyncio."""
22
# pylint: disable=missing-type-doc
33
import logging
44
import asyncio
@@ -61,48 +61,6 @@ def reactor_factory(
6161
return protocol, deferred
6262

6363

64-
def io_loop_factory(
65-
host="127.0.0.1",
66-
port=Defaults.Port,
67-
framer=None,
68-
source_address=None,
69-
timeout=None,
70-
**kwargs,
71-
):
72-
"""Create Tornado based asynchronous tcp clients.
73-
74-
:param host: Host IP address
75-
:param port: Port
76-
:param framer: Modbus Framer
77-
:param source_address: Bind address
78-
:param timeout: Timeout in seconds
79-
:param kwargs:
80-
:return: event_loop_thread and tornado future
81-
"""
82-
from tornado.ioloop import IOLoop # pylint: disable=import-outside-toplevel
83-
from pymodbus.client.asynchronous.tornado import ( # pylint: disable=import-outside-toplevel
84-
AsyncModbusTCPClient as Client,
85-
)
86-
87-
ioloop = IOLoop()
88-
protocol = EventLoopThread("ioloop", ioloop.start, ioloop.stop)
89-
protocol.start()
90-
91-
client = Client(
92-
host=host,
93-
port=port,
94-
framer=framer,
95-
source_address=source_address,
96-
timeout=timeout,
97-
ioloop=ioloop,
98-
**kwargs,
99-
)
100-
101-
future = client.connect()
102-
103-
return protocol, future
104-
105-
10664
def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):
10765
"""Create asyncio based asynchronous tcp clients.
10866
@@ -137,18 +95,16 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):
13795
def get_factory(scheduler):
13896
"""Get protocol factory based on the backend scheduler being used.
13997
140-
:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
98+
:param scheduler: REACTOR/ASYNC_IO
14199
:return: new factory
142100
:raises Exception: Failure
143101
"""
144102
if scheduler == schedulers.REACTOR:
145103
return reactor_factory
146-
if scheduler == schedulers.IO_LOOP:
147-
return io_loop_factory
148104
if scheduler == schedulers.ASYNC_IO:
149105
return async_io_factory
150106

151-
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.IO_LOOP}, {schedulers.ASYNC_IO}"
107+
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.ASYNC_IO}"
152108
_logger.warning(txt)
153109
txt = f'Invalid Scheduler "{scheduler}"'
154110
raise Exception(txt)

pymodbus/client/asynchronous/factory/udp.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from pymodbus.client.asynchronous.async_io import init_udp_client
77
from pymodbus.client.asynchronous import schedulers
8-
from pymodbus.client.asynchronous.thread import EventLoopThread
98
from pymodbus.constants import Defaults
109

1110
_logger = logging.getLogger(__name__)
@@ -32,44 +31,6 @@ def reactor_factory(
3231
raise NotImplementedError()
3332

3433

35-
def io_loop_factory(
36-
host="127.0.0.1",
37-
port=Defaults.Port,
38-
framer=None,
39-
source_address=None,
40-
timeout=None,
41-
**kwargs,
42-
):
43-
"""Create Tornado based asynchronous udp clients.
44-
45-
:param host: Host IP address
46-
:param port: Port
47-
:param framer: Modbus Framer
48-
:param source_address: Bind address
49-
:param timeout: Timeout in seconds
50-
:param kwargs:
51-
:return: event_loop_thread and tornado future
52-
"""
53-
from tornado.ioloop import IOLoop # pylint: disable=import-outside-toplevel
54-
from pymodbus.client.asynchronous.tornado import ( # pylint: disable=import-outside-toplevel
55-
AsyncModbusUDPClient as Client,
56-
)
57-
58-
client = Client(
59-
host=host,
60-
port=port,
61-
framer=framer,
62-
source_address=source_address,
63-
timeout=timeout,
64-
**kwargs,
65-
)
66-
protocol = EventLoopThread("ioloop", IOLoop.current().start, IOLoop.current().stop)
67-
protocol.start()
68-
future = client.connect()
69-
70-
return protocol, future
71-
72-
7334
def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):
7435
"""Create asyncio based asynchronous udp clients.
7536
@@ -101,18 +62,16 @@ def async_io_factory(host="127.0.0.1", port=Defaults.Port, **kwargs):
10162
def get_factory(scheduler):
10263
"""Get protocol factory based on the backend scheduler being used.
10364
104-
:param scheduler: REACTOR/IO_LOOP/ASYNC_IO
65+
:param scheduler: REACTOR/ASYNC_IO
10566
:return: new factory
10667
:raises Exception: Failure
10768
"""
10869
if scheduler == schedulers.REACTOR:
10970
return reactor_factory
110-
if scheduler == schedulers.IO_LOOP:
111-
return io_loop_factory
11271
if scheduler == schedulers.ASYNC_IO:
11372
return async_io_factory
11473

115-
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.IO_LOOP}, {schedulers.ASYNC_IO}"
74+
txt = f"Allowed Schedulers: {schedulers.REACTOR}, {schedulers.ASYNC_IO}"
11675
_logger.warning(txt)
11776
txt = f'Invalid Scheduler "{scheduler}"'
11877
raise Exception(txt)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Backend schedulers to use with generic Async clients."""
22

33
REACTOR = "reactor"
4-
IO_LOOP = "io_loop"
54
ASYNC_IO = "async_io"

pymodbus/client/asynchronous/thread.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
class EventLoopThread:
99
"""Event loop controlling the backend event loops.
1010
11-
io_loop for tornado,
1211
reactor for twisted,
1312
event_loop for Asyncio
1413
"""

0 commit comments

Comments
 (0)