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):
time.sleep(2)
with self._app.app_context():
import item.scan
item.scan.run_scan()
while self._running:
self.download_next()
time.sleep(0.5)

View File

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

View File

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

View File

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