Hallon
Hallon copied to clipboard
Artist won't load (even after a long time)
Hey. I'm interested in writing a small script to find random related artists based on the artists I have in my playlist, but I'm having difficulties using Hallon because it doesn't seem to load things successfully.
I did the following things:
- Installed the Hallon gem
- Got an api key and downloaded it to a directory
- I ran pry and tried fiddling with the API.
I read in another issue that some loading might go on for even longer than a minute, but I think it's been hanging for way longer than that and I've had no result, so I wonder if I'm doing something wrong. Please excuse me if I missed something.
Here's what I tried:
$ pry
[1] pry(main)> require 'hallon'
=> true
[2] pry(main)> session = Hallon::Session.initialize(IO.read("./spotify_appkey.key"))
=> #<Hallon::Session:0x007ff32dbb7d80
@__observable__hubs__=
{70341209551640=>
#<Set: {#<WeakObservable:0x007ff32dbb7448
@callbacks={#<Hallon::Session:0x007ff32dbb7d80 ...>=>:trigger},
@monitor=
#<Ref::SafeMonitor:0x007ff32dbb7420
@count=0,
@mutex=#<Mutex:0x007ff32dbb73f8>,
@owner=nil>,
@observers=
{-2430667430642102391=>#<Hallon::Session:0x007ff32dbb7d80 ...>}>}>},
@cache_size=0,
@options=
{:user_agent=>"Hallon",
:settings_location=>"tmp/hallon/",
:cache_location=>"tmp/hallon/",
:compress_playlists=>true,
:device_id=>nil,
:proxy=>nil,
:proxy_username=>nil,
:proxy_password=>nil,
:tracefile=>nil,
[3] pry(main)> artist = Hallon::Artist.new("spotify:artist:62k5LKMhymqlDNo2DWOvvv").load
Hallon::TimeoutError: execution expired
from /Users/gabriele/.rvm/gems/ruby-2.0.0-p247/gems/hallon-0.18.2/lib/hallon/loadable.rb:24:in `sleep'
[4] pry(main)> Hallon.load_timeout = 0
=> 0
[5] pry(main)> artist = Hallon::Artist.new("spotify:artist:62k5LKMhymqlDNo2DWOvvv").load
I also checked if I have the correct gems installed:
$ gem list|grep spotify
libspotify (12.1.51.3 universal-darwin)
spotify (12.5.2)
Hi, I don’t really do development on Hallon anymore but I figured it would be nice to have an answer either way.
The issue with objects never loading has been in Hallon since it’s inception. Sometimes objects never load, and it is not uncommon. I believe there are multiple reasons for this:
- libspotify was never intended to be used anywhere without an event loop
- possible deadlock/spinlock bugs in Hallon starving libspotify of work
The timeout in Hallon was a naive way of working around this, by making non-loading objects an error, which is why the timeout exists in the first place. However, where libspotify is usually used (e.g. spotify client), an object not loading is not usually that big of a deal, it simply won’t show any information. It makes it tricky to use libspotify in one-off scripts in ruby, but I do not believe there is any other way around it than completely changing how libspotify is used in Ruby, with something like celluloid or eventmachine for example.