Improved UX a bit: all threads are immediately started;

no more slow starting of modules.

Although I'm highly unsatisfied with the current implementation
(SoC, you hear me!?)
This commit is contained in:
enkore 2013-03-10 02:11:58 +01:00
parent 375ba3af7b
commit c8c8e2226f
4 changed files with 20 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import sys
import threading
from .core import util, io
from .core.modules import *
from .core.modules import Module, AsyncModule, IntervalModule, START_HOOKS
from .core.settings import SettingsBase
from .core.config import ConfigFinder
@ -43,7 +43,12 @@ class Status:
if module:
module.on_click(j["button"])
def call_start_hooks(self):
for hook in START_HOOKS:
hook()
def run(self):
self.call_start_hooks()
for j in io.JSONIO(self.io).read():
for module in self.modules:
module.inject(j)

View File

@ -57,6 +57,11 @@ class IntervalModule(Module):
am.append(self)
IntervalModule.managers[self.interval] = am
@classmethod
def _start(cls):
for manager in cls.managers.values():
manager.start()
def __call__(self):
self.run()
@ -65,3 +70,7 @@ class IntervalModule(Module):
Do not rely on this being called from the same thread at all times.
If you need to always have the same thread context, subclass AsyncModule."""
START_HOOKS = (
IntervalModule._start,
)

View File

@ -89,7 +89,6 @@ class AutomagicManager:
initial_thread = Thread(target_interval, [self.wrap(self)])
self.threads = [initial_thread]
initial_thread.start()
def __call__(self):
separate = []
@ -126,3 +125,7 @@ class AutomagicManager:
def append(self, workload):
self.threads[0].append(self.wrap(workload))
def start(self):
for thread in self.threads:
thread.start()

View File

@ -3,7 +3,7 @@
from setuptools import setup
setup(name="i3pystatus",
version="3.9",
version="3.10",
description="Like i3status, this generates status line for i3bar / i3wm",
url="http://github.com/enkore/i3pystatus",
license="MIT",