Skip to content

Commit

Permalink
Remove handler= for server classes. (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Jun 14, 2023
1 parent 0a22dbb commit 1cd8d33
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 26 deletions.
1 change: 1 addition & 0 deletions API_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PyModbus - API changes.
Version 3.4.0
-------------
- Modbus<x>Client .connect() returns True/False (connected or not)
- Modbue<x>Server handler= no longer accepted

-------------
Version 3.3.1
Expand Down
4 changes: 0 additions & 4 deletions examples/server_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async def run_async_server(args):
address=address, # listen address
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
allow_reuse_address=True, # allow the reuse of an address
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
Expand All @@ -169,7 +168,6 @@ async def run_async_server(args):
address=address, # listen address
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
Expand All @@ -185,7 +183,6 @@ async def run_async_server(args):
port=args.port, # serial port
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
# stopbits=1, # The number of stop bits to use
# bytesize=8, # The bytesize of the serial messages
# parity="N", # Which kind of parity to use
Expand All @@ -205,7 +202,6 @@ async def run_async_server(args):
# custom_functions=[], # allow custom handling
address=address, # listen address
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
allow_reuse_address=True, # allow the reuse of an address
certfile=helper.get_certificate(
"crt"
Expand Down
4 changes: 0 additions & 4 deletions examples/server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def run_sync_server(args):
address=address, # listen address
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# TBD handler=None, # handler for each session
allow_reuse_address=True, # allow the reuse of an address
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
Expand All @@ -81,7 +80,6 @@ def run_sync_server(args):
address=address, # listen address
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# TBD handler=None, # handler for each session
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat slave_id 0 as broadcast address,
# timeout=1, # waiting time for request to complete
Expand All @@ -97,7 +95,6 @@ def run_sync_server(args):
port=args.port, # serial port
# custom_functions=[], # allow custom handling
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
# stopbits=1, # The number of stop bits to use
# bytesize=7, # The bytesize of the serial messages
# parity="E", # Which kind of parity to use
Expand All @@ -117,7 +114,6 @@ def run_sync_server(args):
# custom_functions=[], # allow custom handling
address=address, # listen address
framer=args.framer, # The framer strategy to use
# handler=None, # handler for each session
allow_reuse_address=True, # allow the reuse of an address
certfile=helper.get_certificate(
"crt"
Expand Down
22 changes: 4 additions & 18 deletions pymodbus/server/async_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def sslctx_provider(
class ModbusBaseRequestHandler(asyncio.BaseProtocol):
"""Implements modbus slave wire protocol.
This uses the asyncio.Protocol to implement the client handler.
This uses the asyncio.Protocol to implement the server protocol.
When a connection is established, the asyncio.Protocol.connection_made
callback is called. This callback will setup the connection and
Expand Down Expand Up @@ -491,7 +491,6 @@ def __init__(
path,
framer=None,
identity=None,
handler=None,
**kwargs,
):
"""Initialize the socket server.
Expand All @@ -503,9 +502,6 @@ def __init__(
:param path: unix socket path
:param framer: The framer strategy to use
:param identity: An optional identify structure
:param handler: A handler for each client session; default is
ModbusConnectedRequestHandler. The handler class
receives connection create/teardown events
:param allow_reuse_address: Whether the server will allow the
reuse of an address.
:param ignore_missing_slaves: True to not send errors on a request
Expand All @@ -522,7 +518,7 @@ def __init__(
self.context = context or ModbusServerContext()
self.control = ModbusControlBlock()
self.path = path
self.handler = handler or ModbusConnectedRequestHandler
self.handler = ModbusConnectedRequestHandler
self.handler.server = self
self.ignore_missing_slaves = kwargs.get(
"ignore_missing_slaves", Defaults.IgnoreMissingSlaves
Expand Down Expand Up @@ -594,7 +590,6 @@ def __init__(
framer=None,
identity=None,
address=None,
handler=None,
allow_reuse_address=False,
backlog=20,
**kwargs,
Expand All @@ -608,9 +603,6 @@ def __init__(
:param framer: The framer strategy to use
:param identity: An optional identify structure
:param address: An optional (interface, port) to bind to.
:param handler: A handler for each client session; default is
ModbusConnectedRequestHandler. The handler class
receives connection create/teardown events
:param allow_reuse_address: Whether the server will allow the
reuse of an address.
:param backlog: is the maximum number of queued connections
Expand All @@ -631,7 +623,7 @@ def __init__(
self.context = context or ModbusServerContext()
self.control = ModbusControlBlock()
self.address = address or ("", Defaults.TcpPort)
self.handler = handler or ModbusConnectedRequestHandler
self.handler = ModbusConnectedRequestHandler
self.handler.server = self
self.ignore_missing_slaves = kwargs.get(
"ignore_missing_slaves", Defaults.IgnoreMissingSlaves
Expand Down Expand Up @@ -717,7 +709,6 @@ def __init__( # pylint: disable=too-many-arguments
keyfile=None,
password=None,
reqclicert=False,
handler=None,
allow_reuse_address=False,
backlog=20,
**kwargs,
Expand All @@ -737,9 +728,6 @@ def __init__( # pylint: disable=too-many-arguments
:param keyfile: The key file path for TLS (used if sslctx is None)
:param password: The password for for decrypting the private key file
:param reqclicert: Force the sever request client's certificate
:param handler: A handler for each client session; default is
ModbusConnectedRequestHandler. The handler class
receives connection create/teardown events
:param allow_reuse_address: Whether the server will allow the
reuse of an address.
:param backlog: is the maximum number of queued connections
Expand All @@ -757,7 +745,6 @@ def __init__( # pylint: disable=too-many-arguments
framer=framer,
identity=identity,
address=address,
handler=handler,
allow_reuse_address=allow_reuse_address,
backlog=backlog,
**kwargs,
Expand All @@ -780,7 +767,6 @@ def __init__(
framer=None,
identity=None,
address=None,
handler=None,
backlog=20,
**kwargs,
):
Expand Down Expand Up @@ -811,7 +797,7 @@ def __init__(
self.context = context or ModbusServerContext()
self.control = ModbusControlBlock()
self.address = address or ("", Defaults.TcpPort)
self.handler = handler or ModbusDisconnectedRequestHandler
self.handler = ModbusDisconnectedRequestHandler
self.ignore_missing_slaves = kwargs.get(
"ignore_missing_slaves", Defaults.IgnoreMissingSlaves
)
Expand Down

0 comments on commit 1cd8d33

Please sign in to comment.