Let's remove that synchronous functionality alltogether.

It simply isn't in the spirit of this app :-)
And nobody uses it.
This commit is contained in:
enkore 2013-02-18 18:00:16 +01:00
parent 84fdbfaff3
commit 1d4403e308

View File

@ -7,19 +7,13 @@ from threading import Thread
import time import time
from contextlib import contextmanager from contextlib import contextmanager
class BaseModule: class Module:
output = None output = None
def registered(self, status_handler): def registered(self, status_handler):
"""Called when this module is registered with a status handler""" """Called when this module is registered with a status handler"""
def tick(self): class AsyncModule(Module):
"""Called once per tick"""
class Module(BaseModule):
pass
class AsyncModule(BaseModule):
def registered(self, status_handler): def registered(self, status_handler):
self.thread = Thread(target=self.mainloop) self.thread = Thread(target=self.mainloop)
self.thread.daemon = True self.thread.daemon = True
@ -80,7 +74,6 @@ class JSONIO:
j = json.loads(line) j = json.loads(line)
yield j yield j
self.io.write(prefix + json.dumps(j)) self.io.write(prefix + json.dumps(j))
class I3statusHandler: class I3statusHandler:
@ -104,8 +97,6 @@ class I3statusHandler:
while True: while True:
with jio.read() as j: with jio.read() as j:
for module in self.modules: for module in self.modules:
module.tick()
output = module.output output = module.output
if output: if output:
j.insert(0, output) j.insert(0, output)