From 756d1d9b99984ef27bcca57dd5217fd5298371c3 Mon Sep 17 00:00:00 2001 From: Chrys Date: Wed, 21 Jun 2017 15:05:38 +0200 Subject: [PATCH] do some ajustments, and fix typos --- src/fenrir/commands/commands/quit_fenrir.py | 2 +- src/fenrir/core/eventManager.py | 18 +++++++++++------- src/fenrir/core/fenrirManager.py | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/fenrir/commands/commands/quit_fenrir.py b/src/fenrir/commands/commands/quit_fenrir.py index 2ddae36f..ea633658 100644 --- a/src/fenrir/commands/commands/quit_fenrir.py +++ b/src/fenrir/commands/commands/quit_fenrir.py @@ -17,7 +17,7 @@ class command(): return _('exits Fenrir') def run(self): - self.env['eventManager'].stopMainEventLoop() + self.env['runtime']['eventManager'].stopMainEventLoop() def setCallback(self, callback): pass diff --git a/src/fenrir/core/eventManager.py b/src/fenrir/core/eventManager.py index b6b0e006..ec34570e 100644 --- a/src/fenrir/core/eventManager.py +++ b/src/fenrir/core/eventManager.py @@ -41,7 +41,7 @@ class eventManager(): self.terminateAllProcesses() self.cleanEventQueue() def timerProcess(self): - time.sleep(0.005) + time.sleep(0.04) #self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay') return time.time() def terminateAllProcesses(self): @@ -60,6 +60,7 @@ class eventManager(): return elif event['Type'] == fenrirEventType.StopMainLoop: self._mainLoopRunning.value = 0 + print('stop') return elif event['Type'] == fenrirEventType.ScreenUpdate: print('do an update') @@ -76,22 +77,25 @@ class eventManager(): pass elif event['Type'] == fenrirEventType.HeartBeat: self.env['runtime']['fenrirManager'].handleProcess() + print(self._eventQueue.qsize()) print('HeartBeat at ' + str(event['Type']) + ' ' +str(event['Data'] )) def startMainEventLoop(self): - self._mainLoopRunning.value = True - while(self._mainLoopRunning.value): + self._mainLoopRunning.value = 1 + while(self._mainLoopRunning.value == 1): + st = time.time() self.proceedEventLoop() + print('loop ' + str(time.time() - st)) def stopMainEventLoop(self, Force = False): if Force: - self._mainLoopRunning.value = False + self._mainLoopRunning.value = 0 self._eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None}) def addCustomEventThread(self, function): - self._mainLoopRunning.value = True + self._mainLoopRunning.value = 1 t = Process(target=self.eventWorkerThread, args=(q, function)) self._eventProcesses.append(t) t.start() def addSimpleEventThread(self, event, function): - self._mainLoopRunning.value = True + self._mainLoopRunning.value = 1 t = Process(target=self.simpleEventWorkerThread, args=(event, function)) self._eventProcesses.append(t) t.start() @@ -124,7 +128,7 @@ class eventManager(): return if not callable(function): return - while self._mainLoopRunning.value: + while self._mainLoopRunning.value == 1: Data = None try: Data = function() diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index e22d252e..e9a8a874 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -109,16 +109,16 @@ class fenrirManager(): self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands') def shutdownRequest(self): - self.environment['eventManager'].stopMainEventLoop() + self.environment['runtime']['eventManager'].stopMainEventLoop() def captureSignal(self, siginit, frame): self.shutdownRequest() def shutdown(self): - self.environment['eventManager'].stopMainEventLoop() + self.environment['runtime']['eventManager'].stopMainEventLoop() self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True) - self.environment['eventManager'].cleanEventQueue() - self.environment['eventManager'].stopMainEventLoop(True) + self.environment['runtime']['eventManager'].cleanEventQueue() + self.environment['runtime']['eventManager'].stopMainEventLoop(True) for currManager in self.environment['general']['managerList']: if self.environment['runtime'][currManager]: self.environment['runtime'][currManager].shutdown()