Event loop¶
-
class
spotify.EventLoop(session)[source]¶ Event loop for automatically processing events from libspotify.
The event loop is a
Threadthat listens toNOTIFY_MAIN_THREADevents and callsprocess_events()when needed.To use it, pass it your
Sessioninstance and callstart():>>> session = spotify.Session() >>> event_loop = spotify.EventLoop(session) >>> event_loop.start()
The event loop thread is a daemon thread, so it will not stop your application from exiting. If you wish to stop the event loop without stopping your entire application, call
stop(). You may calljoin()to block until the event loop thread has finished, just like for any other thread.Warning
If you use
EventLoopto process the libspotify events, any event listeners you’ve registered will be called from the event loop thread. pyspotify itself is thread safe, but you’ll need to ensure that you have proper synchronization in your own application code, as always when working with threads.