Give all threads a reference to core_queue
This commit is contained in:
parent
b3fea05ef0
commit
11e48083ee
@ -19,7 +19,7 @@ class LibspotifySessionManager(SpotifySessionManager, BaseThread):
|
||||
|
||||
def __init__(self, username, password, core_queue, output):
|
||||
SpotifySessionManager.__init__(self, username, password)
|
||||
BaseThread.__init__(self)
|
||||
BaseThread.__init__(self, core_queue)
|
||||
self.name = 'LibspotifySMThread'
|
||||
# Run as a daemon thread, so Mopidy won't wait for this thread to exit
|
||||
# before Mopidy exits.
|
||||
|
||||
@ -13,8 +13,9 @@ logger = logging.getLogger('mopidy.core')
|
||||
|
||||
class CoreProcess(BaseThread):
|
||||
def __init__(self):
|
||||
super(CoreProcess, self).__init__(name='CoreProcess')
|
||||
self.core_queue = multiprocessing.Queue()
|
||||
super(CoreProcess, self).__init__(self.core_queue)
|
||||
self.name = 'CoreProcess'
|
||||
self.options = self.parse_options()
|
||||
self.output = None
|
||||
self.backend = None
|
||||
|
||||
@ -45,7 +45,7 @@ class LastfmFrontend(BaseFrontend):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LastfmFrontend, self).__init__(*args, **kwargs)
|
||||
(self.connection, other_end) = multiprocessing.Pipe()
|
||||
self.thread = LastfmFrontendThread(other_end)
|
||||
self.thread = LastfmFrontendThread(self.core_queue, other_end)
|
||||
|
||||
def start(self):
|
||||
self.thread.start()
|
||||
@ -58,8 +58,8 @@ class LastfmFrontend(BaseFrontend):
|
||||
|
||||
|
||||
class LastfmFrontendThread(BaseThread):
|
||||
def __init__(self, connection):
|
||||
super(LastfmFrontendThread, self).__init__()
|
||||
def __init__(self, core_queue, connection):
|
||||
super(LastfmFrontendThread, self).__init__(core_queue)
|
||||
self.name = u'LastfmFrontendThread'
|
||||
self.daemon = True
|
||||
self.connection = connection
|
||||
|
||||
@ -8,7 +8,7 @@ logger = logging.getLogger('mopidy.frontends.mpd.thread')
|
||||
|
||||
class MpdThread(BaseThread):
|
||||
def __init__(self, core_queue):
|
||||
super(MpdThread, self).__init__()
|
||||
super(MpdThread, self).__init__(core_queue)
|
||||
self.name = u'MpdThread'
|
||||
self.daemon = True
|
||||
self.core_queue = core_queue
|
||||
|
||||
@ -29,7 +29,7 @@ class GStreamerOutput(BaseOutput):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(GStreamerOutput, self).__init__(*args, **kwargs)
|
||||
# Start a helper thread that can run the gobject.MainLoop
|
||||
self.messages_thread = GStreamerMessagesThread()
|
||||
self.messages_thread = GStreamerMessagesThread(self.core_queue)
|
||||
|
||||
# Start a helper thread that can process the output_queue
|
||||
self.output_queue = multiprocessing.Queue()
|
||||
@ -91,8 +91,8 @@ class GStreamerOutput(BaseOutput):
|
||||
|
||||
|
||||
class GStreamerMessagesThread(BaseThread):
|
||||
def __init__(self):
|
||||
super(GStreamerMessagesThread, self).__init__()
|
||||
def __init__(self, core_queue):
|
||||
super(GStreamerMessagesThread, self).__init__(core_queue)
|
||||
self.name = u'GStreamerMessagesThread'
|
||||
self.daemon = True
|
||||
|
||||
@ -113,7 +113,7 @@ class GStreamerPlayerThread(BaseThread):
|
||||
"""
|
||||
|
||||
def __init__(self, core_queue, output_queue):
|
||||
super(GStreamerPlayerThread, self).__init__()
|
||||
super(GStreamerPlayerThread, self).__init__(core_queue)
|
||||
self.name = u'GStreamerPlayerThread'
|
||||
self.daemon = True
|
||||
self.core_queue = core_queue
|
||||
|
||||
@ -19,6 +19,10 @@ def unpickle_connection(pickled_connection):
|
||||
|
||||
|
||||
class BaseProcess(multiprocessing.Process):
|
||||
def __init__(self, core_queue):
|
||||
super(BaseProcess, self).__init__()
|
||||
self.core_queue = core_queue
|
||||
|
||||
def run(self):
|
||||
logger.debug(u'%s: Starting process', self.name)
|
||||
try:
|
||||
@ -44,6 +48,10 @@ class BaseProcess(multiprocessing.Process):
|
||||
|
||||
|
||||
class BaseThread(multiprocessing.dummy.Process):
|
||||
def __init__(self, core_queue):
|
||||
super(BaseThread, self).__init__()
|
||||
self.core_queue = core_queue
|
||||
|
||||
def run(self):
|
||||
logger.debug(u'%s: Starting thread', self.name)
|
||||
try:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user