run every 15m

This commit is contained in:
j 2017-11-02 08:40:02 +00:00
parent 6f35527ca3
commit 0cac482f56
3 changed files with 8 additions and 6 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
json/* json/*
__pycache__/ __pycache__/
*.swp

View file

@ -9,6 +9,8 @@ import random
import ox import ox
from utils import run_async
class Engine: class Engine:
def __init__(self, path): def __init__(self, path):
@ -115,6 +117,10 @@ class Engine:
with open(os.path.join(self.path, 'playlists.json'), 'w') as f: with open(os.path.join(self.path, 'playlists.json'), 'w') as f:
f.write(json.dumps(self.playlists, indent=4, sort_keys=True)) f.write(json.dumps(self.playlists, indent=4, sort_keys=True))
@run_async
def update_async(self):
self.update()
class Pandora: class Pandora:

7
server.py Executable file → Normal file
View file

@ -94,12 +94,7 @@ def main(prefix='json/'):
app.listen(settings['port'], settings['address']) app.listen(settings['port'], settings['address'])
main = IOLoop.instance() main = IOLoop.instance()
@run_async update_cb = PeriodicCallback(engine.update_async, 15*60*1000)
def update():
engine.update()
update_cb = PeriodicCallback(update, 60000)
#main.spawn_callback(update, engine) #main.spawn_callback(update, engine)
#fixme run periodically #fixme run periodically