From 35a10fc53ebada57376a75e543a7101b28a903e2 Mon Sep 17 00:00:00 2001 From: NaruX Date: Sun, 3 Dec 2017 15:00:47 +0100 Subject: [PATCH] =?UTF-8?q?=5F=5Fexec=5Fth=20als=20daemon=20starten=20Devi?= =?UTF-8?q?ces=20zum=20autorefresh=20hinzuf=C3=BCgen=20abgesichert=20mit?= =?UTF-8?q?=20Lock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/revpimodio2.helper.html | 4 ++-- revpimodio2/device.py | 5 ++++- revpimodio2/helper.py | 3 ++- revpimodio2/modio.py | 6 ++++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/revpimodio2.helper.html b/doc/revpimodio2.helper.html index c1c26d0..3ece18f 100644 --- a/doc/revpimodio2.helper.html +++ b/doc/revpimodio2.helper.html @@ -444,7 +444,7 @@ Methods Findet Aenderungen fuer die Eventueberwachung. __exec_th -Fuehrt Events aus, die als Thread registriert wurden. +Laeuft als Thread, der Events als Thread startet. _collect_events Aktiviert oder Deaktiviert die Eventueberwachung. @@ -501,7 +501,7 @@ Findet Aenderungen fuer die Eventueberwachung. ProcimgWriter.__exec_th __exec_th()

-Fuehrt Events aus, die als Thread registriert wurden. +Laeuft als Thread, der Events als Thread startet.

ProcimgWriter._collect_events

diff --git a/revpimodio2/device.py b/revpimodio2/device.py index 1ae8e8b..171dccc 100644 --- a/revpimodio2/device.py +++ b/revpimodio2/device.py @@ -284,7 +284,10 @@ class Device(object): self._filelock.release() self._selfupdate = True - self._modio._lst_refresh.append(self) + + # Sicher in Liste einfügen + with self._modio._imgwriter.lck_refresh: + self._modio._lst_refresh.append(self) # Thread starten, wenn er noch nicht läuft if not self._modio._imgwriter.is_alive(): diff --git a/revpimodio2/helper.py b/revpimodio2/helper.py index 592134f..7d6557a 100644 --- a/revpimodio2/helper.py +++ b/revpimodio2/helper.py @@ -373,7 +373,7 @@ class ProcimgWriter(Thread): dev._ba_datacp = dev._ba_devdata[:] def __exec_th(self): - """Fuehrt Events aus, die als Thread registriert wurden.""" + """Laeuft als Thread, der Events als Thread startet.""" while self.__eventwork: try: tup_fireth = self.__eventqth.get(timeout=1) @@ -400,6 +400,7 @@ class ProcimgWriter(Thread): # Threadmanagement if value and not self.__eventth.is_alive(): self.__eventth = Thread(target=self.__exec_th) + self.__eventth.daemon = True self.__eventth.start() def _get_ioerrors(self): diff --git a/revpimodio2/modio.py b/revpimodio2/modio.py index f6c740e..2934f71 100644 --- a/revpimodio2/modio.py +++ b/revpimodio2/modio.py @@ -414,12 +414,18 @@ class RevPiModIO(object): @param full Entfernt auch alle Devices aus autorefresh""" self._exit.set() self._waitexit.set() + if full: + # ProcimgWriter beenden und darauf warten if self._imgwriter is not None and self._imgwriter.is_alive(): self._imgwriter.stop() self._imgwriter.join(self._imgwriter._refresh) + + # Mainloop beenden und darauf waretn if self._th_mainloop is not None and self._th_mainloop.is_alive(): self._th_mainloop.join(1) + + # Alle Devices aus Autorefresh entfernen while len(self._lst_refresh) > 0: dev = self._lst_refresh.pop() dev._selfupdate = False