mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Make sure notification threads exit on shutdown
This commit is contained in:
parent
2c5d131019
commit
628cef11fa
2 changed files with 11 additions and 2 deletions
|
@ -1050,6 +1050,10 @@ def shutdown(restart=False, update=False, checkout=False):
|
||||||
cherrypy.engine.exit()
|
cherrypy.engine.exit()
|
||||||
SCHED.shutdown(wait=False)
|
SCHED.shutdown(wait=False)
|
||||||
|
|
||||||
|
# Stop the notification threads
|
||||||
|
for i in range(CONFIG.NOTIFICATION_THREADS):
|
||||||
|
NOTIFY_QUEUE.put(None)
|
||||||
|
|
||||||
CONFIG.write()
|
CONFIG.write()
|
||||||
|
|
||||||
if not restart and not update and not checkout:
|
if not restart and not update and not checkout:
|
||||||
|
|
|
@ -41,16 +41,21 @@ def process_queue():
|
||||||
queue = plexpy.NOTIFY_QUEUE
|
queue = plexpy.NOTIFY_QUEUE
|
||||||
while True:
|
while True:
|
||||||
params = queue.get()
|
params = queue.get()
|
||||||
if params:
|
|
||||||
|
if params is None:
|
||||||
|
break
|
||||||
|
elif params:
|
||||||
if 'notifier_id' in params:
|
if 'notifier_id' in params:
|
||||||
notify(**params)
|
notify(**params)
|
||||||
else:
|
else:
|
||||||
add_notifier_each(**params)
|
add_notifier_each(**params)
|
||||||
queue.task_done()
|
queue.task_done()
|
||||||
|
|
||||||
|
logger.info(u"PlexPy NotificationHandler :: Notification thread exiting...")
|
||||||
|
|
||||||
|
|
||||||
def start_threads(num_threads=1):
|
def start_threads(num_threads=1):
|
||||||
logger.info(u"PlexPy NotificationHandler :: Starting background notification handler.")
|
logger.info(u"PlexPy NotificationHandler :: Starting background notification handler ({} threads).".format(num_threads))
|
||||||
for x in range(num_threads):
|
for x in range(num_threads):
|
||||||
thread = threading.Thread(target=process_queue)
|
thread = threading.Thread(target=process_queue)
|
||||||
thread.daemon = True
|
thread.daemon = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue