diff --git a/play zone/epollScreen.py b/play zone/epollScreen.py new file mode 100644 index 00000000..c9f47caf --- /dev/null +++ b/play zone/epollScreen.py @@ -0,0 +1,41 @@ +#!/bin/python + +import select +import time + +vcsa = {} +for i in range(1,7): + vcsa[str(i)] = open('/dev/vcs'+str(i),'rb') + vcsa[str(i)].read() + +tty = open('/sys/devices/virtual/tty/tty0/active','r') + +oldTty = str(tty.read()[3:-1]) +watchdog = select.poll() +watchdog.register(tty, select.EPOLLPRI) +watchdog.register(vcsa[ oldTty ], select.EPOLLPRI) + +while True: + changed = watchdog.poll() + print('-----------------------------') + print(changed,tty.fileno()) + for fileno, event in changed: + if tty.fileno() == fileno: + currTty = tty.seek(0) + #b = open('/sys/devices/virtual/tty/tty0/active','r') + currTty = str(tty.read()[3:-1]) + print('|'+currTty+'|'+oldTty+'|') + if currTty != oldTty: + watchdog.register(vcsa[ currTty ].fileno(), select.EPOLLPRI) + watchdog.unregister(vcsa[ oldTty ].fileno()) + oldTty = currTty + print('new screen ' + currTty) + else: + print('update '+ currTty + ' ' + str(fileno)) + vcsa[currTty].seek(0) + b = vcsa[currTty].read() + #print(b) + time.sleep(0.5) + + + diff --git a/src/fenrir/core/eventManager.py b/src/fenrir/core/eventManager.py index 532b7408..a9a60e12 100644 --- a/src/fenrir/core/eventManager.py +++ b/src/fenrir/core/eventManager.py @@ -41,10 +41,14 @@ class eventManager(): self.terminateAllProcesses() self.cleanEventQueue() def timerProcess(self): - time.sleep(0.03) + try: + time.sleep(0.03) + except: + pass #self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay') return time.time() def terminateAllProcesses(self): + time.sleep(1) for proc in self._eventProcesses: try: proc.terminate() @@ -52,7 +56,9 @@ class eventManager(): print(e) def proceedEventLoop(self): event = self._eventQueue.get() + st = time.time() self.eventDispatcher(event) + print('NET loop ' + str(time.time() - st)) def eventDispatcher(self, event): if not event: return @@ -84,7 +90,7 @@ class eventManager(): while(self._mainLoopRunning.value == 1): st = time.time() self.proceedEventLoop() - print('loop ' + str(time.time() - st)) + print('ALL loop ' + str(time.time() - st)) def stopMainEventLoop(self, Force = False): if Force: self._mainLoopRunning.value = 0