Skip to content

Commit 2a6433a

Browse files
authored
Remove unused FifoTransactionManager. (#1966)
1 parent c59b9fd commit 2a6433a

File tree

2 files changed

+0
-100
lines changed

2 files changed

+0
-100
lines changed

pymodbus/transaction.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Collection of transaction based abstractions."""
22

33
__all__ = [
4-
"FifoTransactionManager",
54
"DictTransactionManager",
65
"ModbusSocketFramer",
76
"ModbusTlsFramer",
@@ -520,56 +519,3 @@ def delTransaction(self, tid):
520519
"""
521520
Log.debug("deleting transaction {}", tid)
522521
self.transactions.pop(tid, None)
523-
524-
525-
class FifoTransactionManager(ModbusTransactionManager):
526-
"""Implements a transaction.
527-
528-
For a manager where the results are returned in a FIFO manner.
529-
"""
530-
531-
def __init__(self, client, **kwargs):
532-
"""Initialize an instance of the ModbusTransactionManager.
533-
534-
:param client: The client socket wrapper
535-
"""
536-
super().__init__(client, **kwargs)
537-
self.transactions = []
538-
539-
def __iter__(self):
540-
"""Iterate over the current managed transactions.
541-
542-
:returns: An iterator of the managed transactions
543-
"""
544-
return iter(self.transactions)
545-
546-
def addTransaction(self, request, tid=None):
547-
"""Add a transaction to the handler.
548-
549-
This holds the requests in case it needs to be resent.
550-
After being sent, the request is removed.
551-
552-
:param request: The request to hold on to
553-
:param tid: The overloaded transaction id to use
554-
"""
555-
tid = tid if tid is not None else request.transaction_id
556-
Log.debug("Adding transaction {}", tid)
557-
self.transactions.append(request)
558-
559-
def getTransaction(self, tid):
560-
"""Return a transaction matching the referenced tid.
561-
562-
If the transaction does not exist, None is returned
563-
564-
:param tid: The transaction to retrieve
565-
"""
566-
return self.transactions.pop(0) if self.transactions else None
567-
568-
def delTransaction(self, tid):
569-
"""Remove a transaction matching the referenced tid.
570-
571-
:param tid: The transaction to remove
572-
"""
573-
Log.debug("Deleting transaction {}", tid)
574-
if self.transactions:
575-
self.transactions.pop(0)

test/test_transaction.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from pymodbus.pdu import ModbusRequest
1414
from pymodbus.transaction import (
1515
DictTransactionManager,
16-
FifoTransactionManager,
1716
ModbusAsciiFramer,
1817
ModbusBinaryFramer,
1918
ModbusRtuFramer,
@@ -37,7 +36,6 @@ class TestTransaction: # pylint: disable=too-many-public-methods
3736
_ascii = None
3837
_binary = None
3938
_manager = None
40-
_queue_manager = None
4139
_tm = None
4240

4341
# ----------------------------------------------------------------------- #
@@ -53,7 +51,6 @@ def setup_method(self):
5351
self._ascii = ModbusAsciiFramer(decoder=self.decoder, client=None)
5452
self._binary = ModbusBinaryFramer(decoder=self.decoder, client=None)
5553
self._manager = DictTransactionManager(self.client)
56-
self._queue_manager = FifoTransactionManager(self.client)
5754
self._tm = ModbusTransactionManager(self.client)
5855

5956
# ----------------------------------------------------------------------- #
@@ -245,49 +242,6 @@ class Request: # pylint: disable=too-few-public-methods
245242
self._manager.delTransaction(handle.transaction_id)
246243
assert not self._manager.getTransaction(handle.transaction_id)
247244

248-
# ----------------------------------------------------------------------- #
249-
# Queue based transaction manager
250-
# ----------------------------------------------------------------------- #
251-
def test_fifo_transaction_manager_tid(self):
252-
"""Test the fifo transaction manager TID."""
253-
for tid in range(1, self._queue_manager.getNextTID() + 10):
254-
assert tid + 1 == self._queue_manager.getNextTID()
255-
self._queue_manager.reset()
256-
assert self._queue_manager.getNextTID() == 1
257-
258-
def test_get_fifo_transaction_manager_transaction(self):
259-
"""Test the fifo transaction manager."""
260-
261-
class Request: # pylint: disable=too-few-public-methods
262-
"""Request."""
263-
264-
self._queue_manager.reset()
265-
handle = Request()
266-
handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init
267-
self._queue_manager.getNextTID()
268-
)
269-
handle.message = b"testing" # pylint: disable=attribute-defined-outside-init
270-
self._queue_manager.addTransaction(handle)
271-
result = self._queue_manager.getTransaction(handle.transaction_id)
272-
assert handle.message == result.message
273-
274-
def test_delete_fifo_transaction_manager_transaction(self):
275-
"""Test the fifo transaction manager."""
276-
277-
class Request: # pylint: disable=too-few-public-methods
278-
"""Request."""
279-
280-
self._queue_manager.reset()
281-
handle = Request()
282-
handle.transaction_id = ( # pylint: disable=attribute-defined-outside-init
283-
self._queue_manager.getNextTID()
284-
)
285-
handle.message = b"testing" # pylint: disable=attribute-defined-outside-init
286-
287-
self._queue_manager.addTransaction(handle)
288-
self._queue_manager.delTransaction(handle.transaction_id)
289-
assert not self._queue_manager.getTransaction(handle.transaction_id)
290-
291245
# ----------------------------------------------------------------------- #
292246
# TCP tests
293247
# ----------------------------------------------------------------------- #

0 commit comments

Comments
 (0)