diff --git a/.gitignore b/.gitignore index 6b9f39e..fe7241d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ json/* __pycache__/ +*.swp diff --git a/recommendation_engine.py b/recommendation_engine.py index 0a44163..abc64a2 100644 --- a/recommendation_engine.py +++ b/recommendation_engine.py @@ -9,6 +9,8 @@ import random import ox +from utils import run_async + class Engine: def __init__(self, path): @@ -115,6 +117,10 @@ class Engine: with open(os.path.join(self.path, 'playlists.json'), 'w') as f: f.write(json.dumps(self.playlists, indent=4, sort_keys=True)) + @run_async + def update_async(self): + self.update() + class Pandora: diff --git a/server.py b/server.py old mode 100755 new mode 100644 index d084f91..02f4276 --- a/server.py +++ b/server.py @@ -94,12 +94,7 @@ def main(prefix='json/'): app.listen(settings['port'], settings['address']) main = IOLoop.instance() - @run_async - def update(): - engine.update() - - update_cb = PeriodicCallback(update, 60000) - + update_cb = PeriodicCallback(engine.update_async, 15*60*1000) #main.spawn_callback(update, engine) #fixme run periodically