summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.py14
-rw-r--r--watcher.py3
2 files changed, 11 insertions, 6 deletions
diff --git a/app.py b/app.py
index ebf0d83..6d604a3 100644
--- a/app.py
+++ b/app.py
@@ -15,10 +15,18 @@ APP = create_app()
if __name__ == "__main__":
config = configparser.ConfigParser()
config.read("mach2.ini")
- watcher = spawn(LibraryWatcher, config.get("DEFAULT", "media_dir"),
- config.get("DEFAULT", "library"))
http_server = WSGIServer(('', 5000), APP, log=None)
server = spawn(http_server.serve_forever)
- joinall([watcher, server])
+ watcher = LibraryWatcher(config.get("DEFAULT", "media_dir"),
+ config.get("DEFAULT", "library"))
+
+ def check_for_events():
+ """Check for changes in the library."""
+ while True:
+ watcher.check_for_events()
+
+ watcher_routine = spawn(check_for_events)
+
+ joinall([watcher_routine, server])
diff --git a/watcher.py b/watcher.py
index ffb4a42..353636a 100644
--- a/watcher.py
+++ b/watcher.py
@@ -126,9 +126,6 @@ class LibraryWatcher(object):
register(self.stop)
- while True:
- self.check_for_events()
-
def stop(self):
"""Remove all the watched paths."""
if self.wdd[self.path] > 0: