]> www.vanbest.org Git - motioneye-debian/commitdiff
mjpg clients are now closed before stopping motion
authorCalin Crisan <ccrisan@gmail.com>
Sun, 6 Oct 2013 19:38:21 +0000 (22:38 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 6 Oct 2013 19:38:21 +0000 (22:38 +0300)
src/mjpgclient.py
src/motionctl.py

index 9280bdb569a0ed4dd6a7cb0224f8ab823f0dc225..b0ac554dc856ecdd62de82ef1ae3c3ee3d614a7a 100644 (file)
@@ -6,7 +6,7 @@ import socket
 from tornado import iostream
 
 import config
-
+import motionctl
 
 
 class MjpgClient(iostream.IOStream):
@@ -94,6 +94,9 @@ class MjpgClient(iostream.IOStream):
 
 
 def get_jpg(camera_id):
+    if not motionctl.running():
+        return None
+    
     if camera_id not in MjpgClient.clients:
         # TODO implement some kind of timeout before retry here
         logging.debug('creating mjpg client for camera id %(camera_id)s' % {
@@ -113,3 +116,8 @@ def get_jpg(camera_id):
         return None
 
     return MjpgClient.last_jpgs.get(camera_id)
+
+
+def close_all():
+    for client in MjpgClient.clients.values():
+        client.close()
index 548330fc5f6fc219c29d1d4afaa1ac452ff8f3f6..436b3f076731b1cc6faa6f8576dac7e1ba18b9fa 100644 (file)
@@ -53,8 +53,12 @@ def start():
 
 
 def stop():
+    import mjpgclient
+    
     if not running():
         raise Exception('motion is not running')
+
+    mjpgclient.close_all()
     
     pid = _get_pid()
     if pid is not None: