From: Calin Crisan Date: Sun, 6 Oct 2013 19:38:21 +0000 (+0300) Subject: mjpg clients are now closed before stopping motion X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=aa87e6fc95f0c07091ab137ad3eb71e27a922546;p=motioneye-debian mjpg clients are now closed before stopping motion --- diff --git a/src/mjpgclient.py b/src/mjpgclient.py index 9280bdb..b0ac554 100644 --- a/src/mjpgclient.py +++ b/src/mjpgclient.py @@ -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() diff --git a/src/motionctl.py b/src/motionctl.py index 548330f..436b3f0 100644 --- a/src/motionctl.py +++ b/src/motionctl.py @@ -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: