use SAQueue and clear cache/queue tables on startup
This commit is contained in:
parent
cffe8cea08
commit
2a0898c928
@ -175,18 +175,19 @@ class Isso(object):
|
|||||||
|
|
||||||
def make_app(conf):
|
def make_app(conf):
|
||||||
|
|
||||||
dbobj = db.Adapter(conf.get("general", "dbpath"))
|
|
||||||
|
|
||||||
if uwsgi is not None:
|
if uwsgi is not None:
|
||||||
cacheobj = cache.uWSGICache(timeout=3600)
|
cacheobj = cache.uWSGICache(timeout=3600)
|
||||||
else:
|
else:
|
||||||
cacheobj = cache.SACache(conf.get("general", "dbpath"), threshold=2048)
|
cacheobj = cache.SACache(conf.get("general", "dbpath"), threshold=2048)
|
||||||
|
|
||||||
|
dbobj = db.Adapter(conf.get("general", "dbpath"))
|
||||||
|
|
||||||
jobs = tasks.Jobs()
|
jobs = tasks.Jobs()
|
||||||
jobs.register("db-purge", dbobj, conf.getint("moderation", "purge-after"))
|
jobs.register("db-purge", dbobj, conf.getint("moderation", "purge-after"))
|
||||||
jobs.register("http-fetch", dbobj)
|
jobs.register("http-fetch", dbobj)
|
||||||
|
|
||||||
queueobj = queue.Queue(1024)
|
queueobj = queue.SAQueue(conf.get("general", "dbpath"), 1024)
|
||||||
worker = queue.Worker(queueobj, jobs)
|
worker = queue.Worker(queueobj, jobs)
|
||||||
|
|
||||||
isso = Isso(conf, cacheobj, dbobj)
|
isso = Isso(conf, cacheobj, dbobj)
|
||||||
|
1
isso/cache/sa.py
vendored
1
isso/cache/sa.py
vendored
@ -71,6 +71,7 @@ class SACache(Base):
|
|||||||
Column("time", Float))
|
Column("time", Float))
|
||||||
|
|
||||||
self.metadata.create_all(self.engine)
|
self.metadata.create_all(self.engine)
|
||||||
|
self.engine.execute(self.cache.delete())
|
||||||
|
|
||||||
def _get(self, ns, key):
|
def _get(self, ns, key):
|
||||||
return get(self.engine.connect(), self.cache, ns + b'-' + key)
|
return get(self.engine.connect(), self.cache, ns + b'-' + key)
|
||||||
|
@ -32,6 +32,7 @@ class SAQueue(Queue):
|
|||||||
Column("wait", Float))
|
Column("wait", Float))
|
||||||
|
|
||||||
self.metadata.create_all(self.engine)
|
self.metadata.create_all(self.engine)
|
||||||
|
self.engine.execute(self.queue.delete())
|
||||||
|
|
||||||
def put(self, item):
|
def put(self, item):
|
||||||
with self.engine.begin() as con:
|
with self.engine.begin() as con:
|
||||||
|
Loading…
Reference in New Issue
Block a user