Add util function for stopping all actors which also tries to stop actors that was started after the function was called

This commit is contained in:
Stein Magnus Jodal 2011-06-10 00:33:14 +02:00
parent b8d4af8367
commit 3cdf1aa35d
2 changed files with 9 additions and 2 deletions

View File

@ -22,7 +22,7 @@ from mopidy.gstreamer import GStreamer
from mopidy.utils import get_class
from mopidy.utils.log import setup_logging
from mopidy.utils.path import get_or_create_folder, get_or_create_file
from mopidy.utils.process import GObjectEventThread
from mopidy.utils.process import GObjectEventThread, stop_all_actors
from mopidy.utils.settings import list_settings_optparse_callback
logger = logging.getLogger('mopidy.core')
@ -42,7 +42,7 @@ def main():
logger.info(u'No actors left. Exiting...')
except KeyboardInterrupt:
logger.info(u'User interrupt. Exiting...')
ActorRegistry.stop_all()
stop_all_actors()
def parse_options():
parser = optparse.OptionParser(version=u'Mopidy %s' % get_version())

View File

@ -5,11 +5,18 @@ import gobject
gobject.threads_init()
from pykka import ActorDeadError
from pykka.registry import ActorRegistry
from mopidy import SettingsError
logger = logging.getLogger('mopidy.utils.process')
def stop_all_actors():
num_actors = len(ActorRegistry.get_all())
while num_actors:
logger.debug(u'Stopping %d actor(s)...', num_actors)
ActorRegistry.stop_all()
num_actors = len(ActorRegistry.get_all())
class BaseThread(threading.Thread):
def __init__(self):