use SAQueue and clear cache/queue tables on startup

This commit is contained in:
Martin Zimmermann 2014-07-25 18:59:35 +02:00
parent cffe8cea08
commit 2a0898c928
3 changed files with 5 additions and 2 deletions

View File

@ -175,18 +175,19 @@ class Isso(object):
def make_app(conf):
dbobj = db.Adapter(conf.get("general", "dbpath"))
if uwsgi is not None:
cacheobj = cache.uWSGICache(timeout=3600)
else:
cacheobj = cache.SACache(conf.get("general", "dbpath"), threshold=2048)
dbobj = db.Adapter(conf.get("general", "dbpath"))
jobs = tasks.Jobs()
jobs.register("db-purge", dbobj, conf.getint("moderation", "purge-after"))
jobs.register("http-fetch", dbobj)
queueobj = queue.Queue(1024)
queueobj = queue.SAQueue(conf.get("general", "dbpath"), 1024)
worker = queue.Worker(queueobj, jobs)
isso = Isso(conf, cacheobj, dbobj)

1
isso/cache/sa.py vendored
View File

@ -71,6 +71,7 @@ class SACache(Base):
Column("time", Float))
self.metadata.create_all(self.engine)
self.engine.execute(self.cache.delete())
def _get(self, ns, key):
return get(self.engine.connect(), self.cache, ns + b'-' + key)

View File

@ -32,6 +32,7 @@ class SAQueue(Queue):
Column("wait", Float))
self.metadata.create_all(self.engine)
self.engine.execute(self.queue.delete())
def put(self, item):
with self.engine.begin() as con: