Replace last multiprocessing.Connection with Queue.Queue

This commit is contained in:
Stein Magnus Jodal 2011-03-23 23:05:20 +01:00
parent b07f37117f
commit 168d6ea434
2 changed files with 6 additions and 8 deletions

View File

@ -1,5 +1,5 @@
import logging
import multiprocessing
import Queue
from spotify import Link, SpotifyError
@ -54,8 +54,6 @@ class SpotifyLibraryProvider(BaseLibraryProvider):
spotify_query.append(u'%s:"%s"' % (field, value))
spotify_query = u' '.join(spotify_query)
logger.debug(u'Spotify search query: %s' % spotify_query)
my_end, other_end = multiprocessing.Pipe()
self.backend.spotify.search(spotify_query.encode(ENCODING), other_end)
my_end.poll(None)
playlist = my_end.recv()
return playlist
queue = Queue.Queue()
self.backend.spotify.search(spotify_query.encode(ENCODING), queue)
return queue.get()

View File

@ -126,13 +126,13 @@ class SpotifySessionManager(BaseThread, PyspotifySessionManager):
self.backend.stored_playlists = playlists
logger.debug(u'Refreshed %d stored playlist(s)', len(playlists))
def search(self, query, connection):
def search(self, query, queue):
"""Search method used by Mopidy backend"""
def callback(results, userdata=None):
# TODO Include results from results.albums(), etc. too
playlist = Playlist(tracks=[
SpotifyTranslator.to_mopidy_track(t)
for t in results.tracks()])
connection.send(playlist)
queue.put(playlist)
self.connected.wait()
self.session.search(query, callback)