From d636f63f6504c9556792a86e5cb82744c1fa6667 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 13 Jul 2013 14:46:48 +0000 Subject: [PATCH] try to avoid thread exceptions on shutdown --- pandora/app/config.py | 13 +++++++++++++ pandora/manage.py | 2 ++ 2 files changed, 15 insertions(+) diff --git a/pandora/app/config.py b/pandora/app/config.py index 0e22156d4..8de4fad47 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -21,6 +21,7 @@ from archive.extract import supported_formats, AVCONV _win = (sys.platform == "win32") RUN_RELOADER = True +NOTIFIER = None def get_version(): info = os.path.join(os.path.dirname(__file__), '..', '..', '.bzr/branch/last-revision') @@ -130,6 +131,7 @@ check the README for further details. def reloader_thread(): + global NOTIFIER settings.RELOADER_RUNNING=True _config_mtime = 0 try: @@ -149,6 +151,7 @@ def reloader_thread(): wm = pyinotify.WatchManager() add_watch() notifier = pyinotify.Notifier(wm) + NOTIFIER = notifier notifier.loop() else: while RUN_RELOADER: @@ -271,3 +274,13 @@ def init(): if not settings.RELOADER_RUNNING: load_config() thread.start_new_thread(reloader_thread, ()) + +def shutdown(): + if settings.RELOADER_RUNNING: + RUN_RELOADER = False + settings.RELOADER_RUNNING = False + if NOTIFIER: + NOTIFIER.stop() + + + diff --git a/pandora/manage.py b/pandora/manage.py index 0d7eb6f7a..4a2d1a851 100755 --- a/pandora/manage.py +++ b/pandora/manage.py @@ -23,3 +23,5 @@ if __name__ == "__main__": sys.stderr.write("Error: Can't find '%s'.\nBefore you run pan.do/ra you must create it\n" % settings.SITE_CONFIG) sys.exit(1) execute_manager(settings) + import app.config + app.config.shutdown()