- class spotify.EventLoop(session)¶
Event loop for automatically processing events from libspotify.
The event loop is a
Threadthat listens to
NOTIFY_MAIN_THREADevents and calls
To use it, pass it your
Sessioninstance and call
>>> 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 call
join()to block until the event loop thread has finished, just like for any other thread.
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.