Common code elimination run

This commit is contained in:
enkore 2013-02-11 21:37:07 +01:00
parent 4c45087a5b
commit 54c14658bc
3 changed files with 7 additions and 15 deletions

View File

@ -38,10 +38,6 @@ class ModsDeChecker(object):
self.cj = http.cookiejar.CookieJar()
self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(self.cj))
self.thread = threading.Thread(target=self.mainloop)
self.thread.daemon = True
self.thread.start()
def mainloop(self):
while True:
unread = self.get_unread_count()

View File

@ -3,6 +3,7 @@
import sys
import json
import urllib.request, urllib.error, urllib.parse
from threading import Thread
class Module(object):
output = None
@ -23,12 +24,6 @@ class I3statusHandler(object):
def register_module(self, module):
"""Register a new module."""
# check if module implemented the
# correct functions
#if not hasattr(module, 'output'):
# raise Exception("Module %s does not implement \
# all the needed functions!".format(module))
self.modules.append(module)
def print_line(self, message):
@ -55,6 +50,12 @@ class I3statusHandler(object):
self.print_line(self.read_line())
self.print_line(self.read_line())
for module in self.modules:
if module.async:
module.thread = Thread(target=module.mainloop)
module.thread.daemon = True
module.thread.start()
while True:
line, prefix = self.read_line(), ''

View File

@ -43,10 +43,6 @@ class ThunderbirdMailChecker(object):
dbus.mainloop.glib.threads_init()
self.context = loop.get_context()
self.thread = threading.Thread(target=self.mainloop)
self.thread.daemon = True
self.thread.start()
def mainloop(self):
while True:
self.context.iteration(False)
@ -75,4 +71,3 @@ class ThunderbirdMailChecker(object):
}
else:
self.output = None