]> www.vanbest.org Git - motioneye-debian/commitdiff
don't allow cleanup and thumbnailer processes to run at the same time
authorCalin Crisan <ccrisan@gmail.com>
Sat, 27 Sep 2014 11:23:09 +0000 (14:23 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 27 Sep 2014 11:48:00 +0000 (14:48 +0300)
.gitignore
src/cleanup.py
src/thumbnailer.py

index 13041b98e2f1eb7f2c49f334d71879ff503c572a..3be82e44ad4e428dac5fb85f75bb055917fb7cf5 100644 (file)
@@ -10,4 +10,5 @@
 settings.py
 conf
 run
-media
\ No newline at end of file
+media
+log
\ No newline at end of file
index c51df0891e3411ae0e73eda3d20896d8e82f88e0..3355af256260142a0c2a75130d581b5aa35a92da 100644 (file)
@@ -24,6 +24,7 @@ import tornado
 
 import mediafiles
 import settings
+import thumbnailer
 
 
 _process = None
@@ -53,17 +54,25 @@ def stop():
 
 
 def running():
-    return _process is not None
+    return _process is not None and _process.is_alive()
 
 
 def _run_process():
     global _process
     
-    # schedule the next call
     ioloop = tornado.ioloop.IOLoop.instance()
-    ioloop.add_timeout(datetime.timedelta(seconds=settings.CLEANUP_INTERVAL), _run_process)
+    
+    if thumbnailer.running():
+        # postpone if thumbnailer is currently running
+        ioloop.add_timeout(datetime.timedelta(seconds=60), _run_process)
+        
+        return
+        
+    else:
+        # schedule the next call
+        ioloop.add_timeout(datetime.timedelta(seconds=settings.CLEANUP_INTERVAL), _run_process)
 
-    if not _process or not _process.is_alive(): # check that the previous process has finished
+    if not running(): # check that the previous process has finished
         logging.debug('running cleanup process...')
 
         _process = multiprocessing.Process(target=_do_cleanup)
index 81037849b38b4f2876e9452c6ba163a363fdcb5b..c70286386708aebf3fc3cfe01143e46ae2895941 100644 (file)
@@ -22,6 +22,7 @@ import os
 import signal
 import tornado
 
+import cleanup
 import mediafiles
 import settings
 
@@ -53,7 +54,7 @@ def stop():
 
 
 def running():
-    return _process is not None
+    return _process is not None and _process.is_alive()
 
 
 def _run_process():
@@ -63,7 +64,7 @@ def _run_process():
     ioloop = tornado.ioloop.IOLoop.instance()
     ioloop.add_timeout(datetime.timedelta(seconds=settings.THUMBNAILER_INTERVAL), _run_process)
 
-    if not _process or not _process.is_alive(): # check that the previous process has finished
+    if not running() and not cleanup.running(): # check that the previous process has finished and that cleanup is not running
         logging.debug('running thumbnailer process...')
 
         _process = multiprocessing.Process(target=_do_next_movie_thumbail)