Add exit_process() function for shutting down Mopidy instead of ActorRegistry.stop_all()
This commit is contained in:
parent
fbc47a041a
commit
2453e6826f
@ -40,11 +40,10 @@ def main():
|
||||
setup_mixer()
|
||||
setup_backend()
|
||||
setup_frontends()
|
||||
while ActorRegistry.get_all():
|
||||
while True:
|
||||
time.sleep(1)
|
||||
logger.info(u'No actors left. Exiting...')
|
||||
except KeyboardInterrupt:
|
||||
logger.info(u'User interrupt. Exiting...')
|
||||
logger.info(u'Interrupted. Exiting...')
|
||||
stop_all_actors()
|
||||
|
||||
def parse_options():
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import signal
|
||||
import thread
|
||||
import threading
|
||||
|
||||
import gobject
|
||||
@ -12,12 +13,17 @@ from mopidy import SettingsError
|
||||
|
||||
logger = logging.getLogger('mopidy.utils.process')
|
||||
|
||||
def exit_process():
|
||||
logger.debug(u'Interrupting main...')
|
||||
thread.interrupt_main()
|
||||
logger.debug(u'Interrupted main')
|
||||
|
||||
def exit_handler(signum, frame):
|
||||
"""A :mod:`signal` handler which will exit the program on signal."""
|
||||
signals = dict((k, v) for v, k in signal.__dict__.iteritems()
|
||||
if v.startswith('SIG') and not v.startswith('SIG_'))
|
||||
logger.info(u'Got %s. Exiting...', signals[signum])
|
||||
stop_all_actors()
|
||||
logger.info(u'Got %s signal', signals[signum])
|
||||
exit_process()
|
||||
|
||||
def stop_all_actors():
|
||||
num_actors = len(ActorRegistry.get_all())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user