Event loop¶
- class spotify.EventLoop(session)[source]¶
Event loop for automatically processing events from libspotify.
The event loop is a
Thread
that listens toNOTIFY_MAIN_THREAD
events and callsprocess_events()
when needed.To use it, pass it your
Session
instance 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
EventLoop
to 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.