From 6644634d988bf25c380b1d0846caab3e2a5d51e9 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Wed, 13 Mar 2024 18:27:46 -0400 Subject: [PATCH] Attempt to introduce flood control. BROKEN. --- src/fenrirscreenreader/core/eventManager.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/fenrirscreenreader/core/eventManager.py b/src/fenrirscreenreader/core/eventManager.py index 49185474..46412ec3 100644 --- a/src/fenrirscreenreader/core/eventManager.py +++ b/src/fenrirscreenreader/core/eventManager.py @@ -82,8 +82,15 @@ class eventManager(): return self._eventQueue def getRunning(self): return self.running + def getEventQueueSize(self): + return self._eventQueue.qsize() def putToEventQueue(self,event, data): if not isinstance(event, fenrirEventType): return False - self._eventQueue.put({"Type":event,"Data":data}) - return True + if event == fenrirEventType.Ignore: + return False + if self.getEventQueueSize() > 40: + if not event in [fenrirEventType.ScreenUpdate, fenrirEventType.HeartBeat]: + self.cleanEventQueue() + self._eventQueue.put({"Type":event,"Data":data}) + return True