scan in tasks queue

This commit is contained in:
j 2014-05-28 17:36:26 +02:00
parent 8ab68826b5
commit 0704e315ba
4 changed files with 5 additions and 6 deletions

View file

@ -35,8 +35,6 @@ class Downloads(Thread):
def run(self): def run(self):
time.sleep(2) time.sleep(2)
with self._app.app_context(): with self._app.app_context():
import item.scan
item.scan.run_scan()
while self._running: while self._running:
self.download_next() self.download_next()
time.sleep(0.5) time.sleep(0.5)

View file

@ -54,7 +54,7 @@ def metadata(f, from_=None):
data[key] = info[key] data[key] = info[key]
if key in opf_info: if key in opf_info:
data[key] = opf_info[key] data[key] = opf_info[key]
if key in data[key]: if key in data:
if isinstance(data[key], basestring): if isinstance(data[key], basestring):
data[key] = data[key].replace('\x00', '') data[key] = data[key].replace('\x00', '')
elif isinstance(data[key], list): elif isinstance(data[key], list):

View file

@ -17,6 +17,7 @@ import state
import node.server import node.server
import oxtornado import oxtornado
from cache import Cache from cache import Cache
import tasks
from item.icons import IconHandler from item.icons import IconHandler
from item.handlers import EpubHandler, ReaderHandler, FileHandler from item.handlers import EpubHandler, ReaderHandler, FileHandler
@ -68,13 +69,12 @@ def run():
state.main = IOLoop.instance() state.main = IOLoop.instance()
state.cache = Cache(ttl=10) state.cache = Cache(ttl=10)
state.tasks = tasks.Tasks(app)
def start_node(): def start_node():
import user import user
import downloads import downloads
import nodes import nodes
import tasks
state.tasks = tasks.Tasks(app)
state.node = node.server.start(app) state.node = node.server.start(app)
state.nodes = nodes.Nodes(app) state.nodes = nodes.Nodes(app)
state.downloads = downloads.Downloads(app) state.downloads = downloads.Downloads(app)

View file

@ -20,6 +20,7 @@ class Tasks(Thread):
Thread.__init__(self) Thread.__init__(self)
self.daemon = True self.daemon = True
self.start() self.start()
self.queue('scan')
def run(self): def run(self):
import item.scan import item.scan
@ -46,6 +47,6 @@ class Tasks(Thread):
self.q.join() self.q.join()
return Thread.join(self) return Thread.join(self)
def queue(self, action, data): def queue(self, action, data=None):
self.q.put((action, data)) self.q.put((action, data))