style: With shared_procimg, save changed outputs in set instead of list

In sets, elements can only occur once. Therefore, no `if` statement
has to check whether the element is already included in the list.

Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
2023-08-16 09:40:36 +02:00
parent 4cb0194f23
commit 70a0721680
3 changed files with 6 additions and 8 deletions

View File

@@ -3,4 +3,4 @@
__author__ = "Sven Sager <akira@revpimodio.org>"
__copyright__ = "Copyright (C) 2023 Sven Sager"
__license__ = "LGPLv2"
__version__ = "2.6.0"
__version__ = "2.6.1rc1"

View File

@@ -155,7 +155,7 @@ class Device(object):
self.__my_io_list = []
self._selfupdate = False
self._shared_procimg = False
self._shared_write = []
self._shared_write = set()
self.shared_procimg(parentmodio._shared_procimg) # Set with register
# Wertzuweisung aus dict_device

View File

@@ -706,10 +706,9 @@ class IOBase(object):
# Für Bitoperationen sperren
self._parentdevice._filelock.acquire()
if self._parentdevice._shared_procimg \
and self not in self._parentdevice._shared_write:
if self._parentdevice._shared_procimg:
# Mark this IO for write operations
self._parentdevice._shared_write.append(self)
self._parentdevice._shared_write.add(self)
# Hier gibt es immer nur ein byte, als int holen
int_byte = self._parentdevice._ba_devdata[self._slc_address.start]
@@ -743,11 +742,10 @@ class IOBase(object):
)
)
if self._parentdevice._shared_procimg \
and self not in self._parentdevice._shared_write:
if self._parentdevice._shared_procimg:
with self._parentdevice._filelock:
# Mark this IO as changed
self._parentdevice._shared_write.append(self)
self._parentdevice._shared_write.add(self)
self._parentdevice._ba_devdata[self._slc_address] = value