From 0b8663c46d02126b06833504424e0bd57a3fa5ee Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 19 Oct 2013 12:56:04 +0300 Subject: [PATCH] motion respawning mechanism is now inhibited after ioloop stop --- doc/todo.txt | 1 - motioneye.py | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/todo.txt b/doc/todo.txt index 03655ac..13f1dc4 100644 --- a/doc/todo.txt +++ b/doc/todo.txt @@ -4,7 +4,6 @@ -> http clients don't die: max_clients limit reached, request queued. 10 active, 217 queued requests. -> remote adding ui could be improved (cleanup fields on ok/on load, no error message until everything is ok) --> kill the motion respawning mechanism on sigint -> add an autoupdate mechanism -> style scroll bars diff --git a/motioneye.py b/motioneye.py index adb4c7e..381d124 100755 --- a/motioneye.py +++ b/motioneye.py @@ -141,11 +141,14 @@ def _start_motion(): # add a motion running checker def checker(): + ioloop = tornado.ioloop.IOLoop.instance() + if not ioloop.running(): # just stopped + return + if not motionctl.running() and config.has_enabled_cameras(): motionctl.start() logging.info('motion started') - ioloop = tornado.ioloop.IOLoop.instance() ioloop.add_timeout(datetime.timedelta(seconds=settings.MOTION_CHECK_INTERVAL), checker) checker() @@ -155,6 +158,10 @@ def _start_cleanup(): import cleanup def do_cleanup(): + ioloop = tornado.ioloop.IOLoop.instance() + if not ioloop.running(): # just stopped + return + try: cleanup.cleanup_images() cleanup.cleanup_movies() @@ -163,7 +170,6 @@ def _start_cleanup(): logging.error('failed to cleanup media files: %(msg)s' % { 'msg': unicode(e)}) - ioloop = tornado.ioloop.IOLoop.instance() ioloop.add_timeout(datetime.timedelta(seconds=settings.CLEANUP_INTERVAL), do_cleanup) do_cleanup() -- 2.39.5